Quansight / ragna

RAG orchestration framework ⛵️
https://ragna.chat
BSD 3-Clause "New" or "Revised" License
181 stars 22 forks source link

Make corpus name part of the protocol rather than a chat protocol parameter #487

Closed pmeier closed 3 months ago

pmeier commented 3 months ago

Initial discussion started in https://github.com/Quansight/ragna/pull/460#discussion_r1692061693. There we decided to just go with a corpus_name: Optional[str] as chat parameter. Same for LanceDB in #461.

However, we likely and up needing a handle for this outside of a chat as well. Think listing the available corpora, or listing the available metadata of a corpus. And if the the corpus_name is a fixed parameter for these endpoints, we should do the same for the protocol methods as well.

Thus, I propose we change the signatures from

to

Downside to this is that calling SourceStorage.store and SourceStorage.retrieve manually will be more annoying, since the corpus_name no longer has a default. But we are not optimizing for this workflow so I'm ok with this compromise.

nenb commented 3 months ago

This seems fine to me. What would be the behaviour if no corpus name is passed?

pmeier commented 3 months ago

What would be the behaviour if no corpus name is passed?

Sorry, forgot to mention that. IMO the behavior should be "author defined". Meaning, the author should put in some behavior for the use case of the user not supplying a corpus name.

For our builtin source storages, we can simply continue to use the "global" corpus:

https://github.com/Quansight/ragna/blob/aea6b6706265e342e41682a88ea80bface4961ec/ragna/source_storages/_chroma.py#L39-L41

https://github.com/Quansight/ragna/blob/aea6b6706265e342e41682a88ea80bface4961ec/ragna/source_storages/_lancedb.py#L55-L57

If we at some point support #191, the behavior would change to "global corpus for the given embedding model".

nenb commented 3 months ago

What should happen if a user wants to chat over multiple corpuses in a single chat?

Should a user be allowed to pass a list of corpus names when instantiating a Chat class? https://github.com/Quansight/ragna/blob/2066dcdeb949060873a8552449b848b245e0e985/ragna/core/_rag.py#L148-L156

pmeier commented 3 months ago

Fixed in #490.