Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Abstract Vector Memory and simple api from plugins #818

Closed
valentimarco opened this issue May 13, 2024 · 10 comments
Closed

[Refactor] Abstract Vector Memory and simple api from plugins #818

valentimarco opened this issue May 13, 2024 · 10 comments
Labels
enhancement New feature or request memory

Comments

@valentimarco
Copy link
Collaborator

valentimarco commented May 13, 2024

  1. Abstract API for the Vectory Memory (so in future we are able to attach different dbs)
  2. Refactor the embedding stuff (@pieroit i don't remember why we need it, wasn't for the tool's examples?)
  3. Add api for doing stuff in plugins, for example 'cat.declerative_memory.filter({})'
@valentimarco valentimarco added enhancement New feature or request memory labels May 13, 2024
@valentimarco valentimarco changed the title [Refactor] Abstract Vector Memory [Refactor] Abstract Vector Memory and simple api from plugins May 13, 2024
@pieroit
Copy link
Member

pieroit commented May 21, 2024

  1. Abstract API for the Vectory Memory (so in future we are able to attach different dbs)

Not strictly necessary to be honest, we fly well with Qdrant. Abstracting is a good idea to encapsulate it and avoid breaking changes coming from them

  1. Refactor the embedding stuff (@pieroit i don't remember why we need it, wasn't for the tool's examples?)

VectorMemoryCollection class has become spaghetti code, it is not on par with other ones

  1. Add api for doing stuff in plugins, for example 'cat.declerative_memory.filter({})'

Nice!

@valentimarco
Copy link
Collaborator Author

valentimarco commented Jun 3, 2024

(03/06 dev meating) in the straycat:

def recall(query: str | Embedding, metadata: dict  = none, search_declerative: bool = true, search_procedural: bool = true, search_episodic: bool = true, override_working_memory: bool = true): Set[Document]

Method to search in memory and must have:

  • query > a string or an embedding
  • metadata > to filter stuff
  • some booleans to do stuff (maybe use **kargs to do that stuff can be clean)

@nicola-corbellini
Copy link
Member

Maybe it can be useful to return also the scores and the embeddings of the recalled points.
E.g., at first, it could return Set[Tuple[str, float, List[float]]] like there is in other parts of the framework.
Probably I'm saying something trivial, but, later on, we could start designing a custom Memory class like

class Memory
    text: str
    embedding: List[float]
    metadata: dict
    score: float (?)
    def to_document(self): -> Document

also, other params for the recall method may be: min_score: float to recall memories with a minimum score, k: int for the max number of memories returned and if k=-1|None the method could just use scroll from qdrant and return all the points.

@valentimarco
Copy link
Collaborator Author

I like the Memory class but should be uniform in all framework

@pieroit
Copy link
Member

pieroit commented Jun 3, 2024

Awesome, agree with @nicola-corbellini on having a custom class to throw memories/points/documents around.
Step 1: Follow the same output as StrayCat.recall_memories_to_working_memory
Step 2: standardize with internal class

About the method, to reelaborate on @valentimarco 's proposal

def recall(
  self,
  query: str | Embedding,
  metadata: dict  = None,
  collection: str | None = None, # searches all by default
  override_working_memory: bool = False
) -> List[Tuple[float, Document]]:

@nickprock
Copy link
Contributor

Hi guys, can I help you on this task?

@pieroit
Copy link
Member

pieroit commented Jul 1, 2024

Hi guys, can I help you on this task?

Hi @nickprock thanks
There is already a PR #848 on the recall function, what of the other topics would you like to tackle?

@nickprock
Copy link
Contributor

Thanks @pieroit but I think I was too far behind on the project, I couldn't get anything right

@pieroit
Copy link
Member

pieroit commented Jul 1, 2024

Thanks @pieroit but I think I was too far behind on the project, I couldn't get anything right

Available anytime for a code tour!

@pieroit
Copy link
Member

pieroit commented Oct 21, 2024

PR in review, merging soon

@pieroit pieroit closed this as completed Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request memory
Projects
None yet
Development

No branches or pull requests

4 participants