Skip to content

Handle error messages using ChromaDB#40

Merged
Maclenn77 merged 2 commits into
mainfrom
development
Jun 14, 2026
Merged

Handle error messages using ChromaDB#40
Maclenn77 merged 2 commits into
mainfrom
development

Conversation

@Maclenn77

Copy link
Copy Markdown
Owner

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:

  • Integrated OpenAIEmbeddingFunction (with the text-embedding-3-small model) into the ChromaClient class, ensuring all collections use the same embedding function for consistency. [1] [2]
  • Updated both get_collection and create_collection methods in chroma_client.py to always use the initialized embedding function when accessing or creating collections.

Search results adjustment:

  • Increased the number of documents returned in the search query from 3 to 5 in the run method of search.py, potentially improving the relevance and breadth of search results.

This pull request improves the handling of the ChromaDB instance 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:

  • The ChromaDB instance is now initialized and stored in st.session_state if it does not already exist, ensuring consistent access across the app (GnosisPages.py).
  • The main chroma_db reference is updated to use the instance from st.session_state instead of creating a new one each time (GnosisPages.py).

Error handling and user feedback:

  • In the Search.run method, 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).
  • Added a check to ensure the collection object has the necessary query method before proceeding, improving robustness (gnosis/search.py).

Dependency management:

  • Added an import for streamlit in gnosis/search.py to support new error handling and state management logic.

@Maclenn77 Maclenn77 merged commit 8954d90 into main Jun 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant