core icon indicating copy to clipboard operation
core copied to clipboard

[Refactor] Abstract Vector Memory and simple api from plugins

Open valentimarco opened this issue 1 year ago • 9 comments

  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 avatar May 13 '24 20:05 valentimarco

  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!

pieroit avatar May 21 '24 15:05 pieroit

(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)

valentimarco avatar Jun 03 '24 18:06 valentimarco

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.

nicola-corbellini avatar Jun 03 '24 19:06 nicola-corbellini

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

valentimarco avatar Jun 03 '24 19:06 valentimarco

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]]:

pieroit avatar Jun 03 '24 22:06 pieroit

Hi guys, can I help you on this task?

nickprock avatar Jun 25 '24 04:06 nickprock

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?

pieroit avatar Jul 01 '24 15:07 pieroit

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

nickprock avatar Jul 01 '24 15:07 nickprock

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 avatar Jul 01 '24 15:07 pieroit

PR in review, merging soon

pieroit avatar Oct 21 '24 18:10 pieroit