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

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

Closed
pmeier opened this issue Aug 12, 2024 · 4 comments
Closed
Labels

Comments

@pmeier
Copy link
Member

pmeier commented Aug 12, 2024

Initial discussion started in #460 (comment). 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

  • def store(self, corpus_name: Optional[str], documents: list[Document])
  • def retrieve(self, corpus_name: Optional[str], metadata_filter: MetadataFilter, prompt: str)

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
Copy link
Contributor

nenb commented Aug 12, 2024

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

@pmeier
Copy link
Member Author

pmeier commented Aug 13, 2024

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:

def _get_collection(self, corpus_name: Optional[str]) -> chromadb.Collection:
if corpus_name is None:
corpus_name = self._embedding_id

def _get_table(self, corpus_name: Optional[str] = None) -> lancedb.table.Table:
if corpus_name is None:
corpus_name = self._embedding_id

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

@nenb
Copy link
Contributor

nenb commented Aug 13, 2024

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?

ragna/ragna/core/_rag.py

Lines 148 to 156 in 2066dcd

def __init__(
self,
rag: Rag,
*,
documents: Iterable[Any],
source_storage: Union[Type[SourceStorage], SourceStorage],
assistant: Union[Type[Assistant], Assistant],
**params: Any,
) -> None:

@pmeier
Copy link
Member Author

pmeier commented Aug 19, 2024

Fixed in #490.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

2 participants