cheshire-cat-ai/core

[Refactor] Abstract Vector Memory and simple api from plugins

Opened this issue · 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({})'
  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!

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

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.

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

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

Hi guys, can I help you on this task?

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?

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

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!