Handle error messages using ChromaDB#40
Merged
Merged
Conversation
Removed unused import of Streamlit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the ChromaDB client to consistently use an OpenAI embedding function and improves the search functionality by retrieving more relevant results. The main changes are focused on integrating the embedding function throughout the collection management methods and adjusting the number of search results returned.
ChromaDB client improvements:
OpenAIEmbeddingFunction(with thetext-embedding-3-smallmodel) into theChromaClientclass, ensuring all collections use the same embedding function for consistency. [1] [2]get_collectionandcreate_collectionmethods inchroma_client.pyto always use the initialized embedding function when accessing or creating collections.Search results adjustment:
runmethod ofsearch.py, potentially improving the relevance and breadth of search results.This pull request improves the handling of the
ChromaDBinstance and enhances error handling for missing API keys and empty document collections in the search functionality. The most important changes are grouped below:Session and state management:
ChromaDBinstance is now initialized and stored inst.session_stateif it does not already exist, ensuring consistent access across the app (GnosisPages.py).chroma_dbreference is updated to use the instance fromst.session_stateinstead of creating a new one each time (GnosisPages.py).Error handling and user feedback:
Search.runmethod, added checks to handle cases where the OpenAI API key is missing, the collection cannot be accessed, or no documents are available, returning clear user-facing error messages (gnosis/search.py).querymethod before proceeding, improving robustness (gnosis/search.py).Dependency management:
streamlitingnosis/search.pyto support new error handling and state management logic.