Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 762e0b8

Browse files
authored
Merge branch 'main' into patch-1
2 parents 7da5962 + d5ce1ad commit 762e0b8

12 files changed

+96
-6
lines changed

docs/embeddings/cohere.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Chroma also provides a convenient wrapper around Cohere's embedding API. This em
2121
This embedding function relies on the `cohere` python package, which you can install with `pip install cohere`.
2222

2323
```python
24+
import chromadb.utils.embedding_functions as embedding_functions
2425
cohere_ef = embedding_functions.CohereEmbeddingFunction(api_key="YOUR_API_KEY", model_name="large")
2526
cohere_ef(texts=["document1","document2"])
2627
```

docs/embeddings/google-gemini.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ This embedding function relies on the `google-generativeai` python package, whic
2424

2525
```python
2626
# import
27-
import chromadb
28-
from chromadb.utils import embedding_functions
27+
import chromadb.utils.embedding_functions as embedding_functions
2928

3029
# use directly
3130
google_ef = embedding_functions.GoogleGenerativeAiEmbeddingFunction(api_key="YOUR_API_KEY")

docs/embeddings/google-palm.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
To use the PaLM embedding API, you must have `google.generativeai` Python package installed and have the API key. To use:
99

1010
```python
11+
import chromadb.utils.embedding_functions as embedding_functions
1112
palm_embedding = embedding_functions.GooglePalmEmbeddingFunction(
1213
api_key=api_key, model=model_name)
1314

docs/embeddings/hugging-face.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Chroma also provides a convenient wrapper around HuggingFace's embedding API. Th
2121
This embedding function relies on the `requests` python package, which you can install with `pip install requests`.
2222

2323
```python
24+
import chromadb.utils.embedding_functions as embedding_functions
2425
huggingface_ef = embedding_functions.HuggingFaceEmbeddingFunction(
2526
api_key="YOUR_API_KEY",
2627
model_name="sentence-transformers/all-MiniLM-L6-v2"

docs/embeddings/instructor.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ There are three models available. The default is `hkunlp/instructor-base`, and f
99

1010
```python
1111
#uses base model and cpu
12+
import chromadb.utils.embedding_functions as embedding_functions
1213
ef = embedding_functions.InstructorEmbeddingFunction()
1314
```
1415
or
1516
```python
17+
import chromadb.utils.embedding_functions as embedding_functions
1618
ef = embedding_functions.InstructorEmbeddingFunction(
1719
model_name="hkunlp/instructor-xl", device="cuda")
1820
```

docs/embeddings/jinaai.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Chroma provides a convenient wrapper around JinaAI's embedding API. This embeddi
2121
This embedding function relies on the `requests` python package, which you can install with `pip install requests`.
2222

2323
```python
24+
import chromadb.utils.embedding_functions as embedding_functions
2425
jinaai_ef = embedding_functions.JinaEmbeddingFunction(
2526
api_key="YOUR_API_KEY",
2627
model_name="jina-embeddings-v2-base-en"

docs/embeddings/openai.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Chroma provides a convenient wrapper around OpenAI's embedding API. This embeddi
2121
This embedding function relies on the `openai` python package, which you can install with `pip install openai`.
2222

2323
```python
24-
import chromadb.utils.embedding_functions
24+
import chromadb.utils.embedding_functions as embedding_functions
2525
openai_ef = embedding_functions.OpenAIEmbeddingFunction(
2626
api_key="YOUR_API_KEY",
2727
model_name="text-embedding-ada-002"
@@ -30,6 +30,7 @@ openai_ef = embedding_functions.OpenAIEmbeddingFunction(
3030

3131
To use the OpenAI embedding models on other platforms such as Azure, you can use the `api_base` and `api_type` parameters:
3232
```python
33+
import chromadb.utils.embedding_functions as embedding_functions
3334
openai_ef = embedding_functions.OpenAIEmbeddingFunction(
3435
api_key="YOUR_API_KEY",
3536
api_base="YOUR_API_BASE_PATH",

docs/integrations/haystack.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
slug: /integrations/haystack
3+
title: 💙 Haystack
4+
---
5+
6+
[Haystack](https://github.com/deepset-ai/haystack) is an open-source LLM framework in Python. It provides [embedders](https://docs.haystack.deepset.ai/v2.0/docs/embedders), [generators](https://docs.haystack.deepset.ai/v2.0/docs/generators) and [rankers](https://docs.haystack.deepset.ai/v2.0/docs/rankers) via a number of LLM providers, tooling for [preprocessing](https://docs.haystack.deepset.ai/v2.0/docs/preprocessors) and data preparation, connectors to a number of vector databases including Chroma and more. Haystack allows you to build custom LLM applications using both components readily available in Haystack and [custom components](https://docs.haystack.deepset.ai/v2.0/docs/custom-components). Some of the most common applications you can build with Haystack are retrieval-augmented generation pipelines (RAG), question-answering and semantic search.
7+
8+
<img src="https://img.shields.io/github/stars/deepset-ai/haystack.svg?style=social&label=Star&maxAge=2400"/>
9+
10+
|[Docs](https://docs.haystack.deepset.ai/v2.0/docs) | [Github](https://github.com/deepset-ai/haystack) | [Haystack Integrations](https://haystack.deepset.ai/integrations) | [Tutorials](https://haystack.deepset.ai/tutorials) |
11+
12+
You can use Chroma together with Haystack by installing the integration and using the `ChromaDocumentStore`
13+
14+
### Installation
15+
16+
```bash
17+
pip install chroma-haystack
18+
```
19+
20+
### Usage
21+
22+
- The [Chroma Integration page](https://haystack.deepset.ai/integrations/chroma-documentstore)
23+
- [Chroma + Haystack Example](https://colab.research.google.com/drive/1YpDetI8BRbObPDEVdfqUcwhEX9UUXP-m?usp=sharing)
24+
25+
#### Write documents into a ChromaDocumentStore
26+
27+
```python
28+
import os
29+
from pathlib import Path
30+
31+
from haystack import Pipeline
32+
from haystack.components.converters import TextFileToDocument
33+
from haystack.components.writers import DocumentWriter
34+
from chroma_haystack import ChromaDocumentStore
35+
36+
file_paths = ["data" / Path(name) for name in os.listdir("data")]
37+
38+
document_store = ChromaDocumentStore()
39+
40+
indexing = Pipeline()
41+
indexing.add_component("converter", TextFileToDocument())
42+
indexing.add_component("writer", DocumentWriter(document_store))
43+
44+
indexing.connect("converter", "writer")
45+
indexing.run({"converter": {"sources": file_paths}})
46+
```
47+
48+
#### Build RAG on top of Chroma
49+
50+
```python
51+
from chroma_haystack.retriever import ChromaQueryRetriever
52+
from haystack.components.generators import HuggingFaceTGIGenerator
53+
from haystack.components.builders import PromptBuilder
54+
55+
prompt = """
56+
Answer the query based on the provided context.
57+
If the context does not contain the answer, say 'Answer not found'.
58+
Context:
59+
{% for doc in documents %}
60+
{{ doc.content }}
61+
{% endfor %}
62+
query: {{query}}
63+
Answer:
64+
"""
65+
prompt_builder = PromptBuilder(template=prompt)
66+
67+
llm = HuggingFaceTGIGenerator(model="mistralai/Mixtral-8x7B-Instruct-v0.1", token='YOUR_HF_TOKEN')
68+
llm.warm_up()
69+
retriever = ChromaQueryRetriever(document_store)
70+
71+
querying = Pipeline()
72+
querying.add_component("retriever", retriever)
73+
querying.add_component("prompt_builder", prompt_builder)
74+
querying.add_component("llm", llm)
75+
76+
querying.connect("retriever.documents", "prompt_builder.documents")
77+
querying.connect("prompt_builder", "llm")
78+
79+
results = querying.run({"retriever": {"queries": [query], "top_k": 3},
80+
"prompt_builder": {"query": query}})
81+
```

docs/integrations/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ We welcome pull requests to add new Integrations to the community.
1919
| [Braintrust](/integrations/braintrust) |||
2020
| [🔭 OpenLLMetry](/integrations/openllmetry) || :soon: |
2121
| [🎈 Streamlit](/integrations/streamlit) |||
22+
| [💙 Haystack](/integrations/haystack) |||
2223

2324
*Coming soon* - integrations with LangSmith, JinaAI, and more.
2425

docs/intro.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ Continue with the full [getting started guide](./getting-started.md).
7575
| Rust ||[from @Anush008](https://crates.io/crates/chromadb) |
7676
| Elixir ||[from @3zcurdia](https://hex.pm/packages/chroma/) |
7777
| Dart ||[from @davidmigloz](https://pub.dev/packages/chromadb) |
78-
| PHP ||[from @HelgeSverre](https://github.com/helgeSverre/chromadb) |
78+
| PHP ||[from @CodeWithKyrian](https://github.com/CodeWithKyrian/chromadb-php) |
79+
| PHP (Laravel) ||[from @HelgeSverre](https://github.com/helgeSverre/chromadb) |
7980
| Other? |||
8081

8182
<br/>

docs/usage-guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ Set the following environment variables:
802802

803803
```bash
804804
export CHROMA_SERVER_AUTH_CREDENTIALS_FILE="server.htpasswd"
805-
export CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER='chromadb.auth.providers.HtpasswdFileServerAuthCredentialsProvider'
806-
export CHROMA_SERVER_AUTH_PROVIDER='chromadb.auth.basic.BasicAuthServerProvider'
805+
export CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER="chromadb.auth.providers.HtpasswdFileServerAuthCredentialsProvider"
806+
export CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.basic.BasicAuthServerProvider"
807807
```
808808

809809
And run the server as normal:

sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const sidebars = {
6868
'integrations/braintrust',
6969
'integrations/openllmetry',
7070
'integrations/streamlit',
71+
'integrations/haystack',
7172
],
7273
},
7374
],

0 commit comments

Comments
 (0)