Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/retrieval_model_clients/ChromadbRM.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Search the chromadb collection for the top `k` passages matching the given query
- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.

**Returns:**
- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with schema `[{"id": str, "score": float, "long_text": str, "metadatas": dict }]`

### Quickstart with OpenAI Embeddings

Expand Down
10 changes: 7 additions & 3 deletions dspy/retrieve/chromadb_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def forward(
query_embeddings=embeddings, n_results=k,
)

passages = [dotdict({"long_text": x}) for x in results["documents"][0]]

return passages
zipped_results = zip(
results["ids"][0],
results["distances"][0],
results["documents"][0],
results["metadatas"][0])
results = [dotdict({"id": id, "score": dist, "long_text": doc, "metadatas": meta }) for id, dist, doc, meta in zipped_results]
return results