DSPy: The framework for programming—not prompting—language models
Python
Update doc
Xiao Cuid48e8eba2d6b
diff --git a/dspy/retrieve/chromadb_rm.py b/dspy/retrieve/chromadb_rm.pyindex 399bcdcc4..fe26318d6 100644--- a/dspy/retrieve/chromadb_rm.py+++ b/dspy/retrieve/chromadb_rm.py@@ -43,6 +43,7 @@ class ChromadbRM(dspy.Retrieve):persist_directory (str): chromadb persist directoryembedding_function (Optional[EmbeddingFunction[Embeddable]]): Optional function to use to embed documents. Defaults to DefaultEmbeddingFunction.k (int, optional): The number of top passages to retrieve. Defaults to 7.+ client(Optional[chromadb.Client]): Optional chromadb client provided by user, default to NoneReturns:dspy.Prediction: An object containing the retrieved passages.@@ -51,12 +52,25 @@ class ChromadbRM(dspy.Retrieve):Below is a code snippet that shows how to use this as the default retriever:```pythonllm = dspy.OpenAI(model="gpt-3.5-turbo")+ # using default chromadb clientretriever_model = ChromadbRM('collection_name', 'db_path')dspy.settings.configure(lm=llm, rm=retriever_model)# to test the retriever with "my query"retriever_model("my query")```+ Use provided chromadb client+ ```python+ import chromadb+ llm = dspy.OpenAI(model="gpt-3.5-turbo")+ # say you have a chromadb running on a different port+ client = chromadb.HttpClient(host='localhost', port=8889)+ retriever_model = ChromadbRM('collection_name', 'db_path', client=client)+ dspy.settings.configure(lm=llm, rm=retriever_model)+ # to test the retriever with "my query"+ retriever_model("my query")+ ```+Below is a code snippet that shows how to use this in the forward() function of a module```pythonself.retrieve = ChromadbRM('collection_name', 'db_path', k=num_passages)@@ -89,7 +103,7 @@ class ChromadbRM(dspy.Retrieve):Args:collection_name (str): chromadb collection namepersist_directory (str): chromadb persist directory- client (chromadb.Client): A chromadb client provided by user+ client (chromadb.Client): chromadb client provided by userReturns: collection per collection_name"""