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
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

# ChromaDB.AgentFramework.Sample

[Microsoft Agent Framework](https://learn.microsoft.com/agent-framework/) samples that use [Chroma](https://www.trychroma.com/) as the vector store, through [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData). They follow the form of the [.NET samples of Agent Framework](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents), with Chroma in place of the vector store of the original sample, and each one also comes with models that run locally in Ollama.
[Microsoft Agent Framework](https://learn.microsoft.com/agent-framework/) samples that use [Chroma](https://www.trychroma.com/) as the vector store through [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData).

They follow the form of the [Agent Framework .NET samples](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents). Chroma takes the place of the vector store that the original sample uses. Each sample also comes in a variant with models that run locally in Ollama.

> This is a community project. It is not affiliated with or endorsed by Chroma.

Expand All @@ -12,14 +14,16 @@ Website: [chromadotnet.org](https://chromadotnet.org)

| Sample | Description |
|---|---|
| [Memory with Chroma](./samples/AgentWithMemory_Step10_MemoryUsingChroma/) | Persists chat history in Chroma with `ChatHistoryMemoryProvider` and recalls it in a new session, with Microsoft Foundry models. In the form of [Memory with Azure Cosmos DB for NoSQL](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step08_MemoryUsingCosmosNoSql). |
| [Memory with Chroma](./samples/AgentWithMemory_Step10_MemoryUsingChroma/) | Persists chat history in Chroma with `ChatHistoryMemoryProvider` and recalls it in a new session. Uses Microsoft Foundry models. Follows the form of [Memory with Azure Cosmos DB for NoSQL](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step08_MemoryUsingCosmosNoSql). |
| [Memory with Chroma and Ollama](./samples/AgentWithMemory_Step10_MemoryUsingChroma_Ollama/) | The same sample with models that run locally in Ollama. |
| [RAG with Chroma](./samples/AgentWithRAG_Step06_ChromaRAG/) | Answers from documentation stored in Chroma with a custom schema, through `TextSearchProvider`, with Microsoft Foundry models. In the form of [RAG with Vector Store and custom schema](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG). |
| [RAG with Chroma](./samples/AgentWithRAG_Step06_ChromaRAG/) | Answers from documentation stored in Chroma with a custom schema, through `TextSearchProvider`. Uses Microsoft Foundry models. Follows the form of [RAG with Vector Store and custom schema](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG). |
| [RAG with Chroma and Ollama](./samples/AgentWithRAG_Step06_ChromaRAG_Ollama/) | The same sample with models that run locally in Ollama. |
| [RAG with Chroma and the TextSearchStore](./samples/AgentWithRAG_Step07_ChromaBasicTextRAG/) | Answers from documents stored in Chroma by the `TextSearchStore` of the Agent Framework sample, which writes and reads them as dictionaries, through `TextSearchProvider`, with Microsoft Foundry models. In the form of [Basic Text RAG](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG). |
| [RAG with Chroma and the TextSearchStore](./samples/AgentWithRAG_Step07_ChromaBasicTextRAG/) | Answers from documents stored in Chroma, through `TextSearchProvider`. The documents are stored by the `TextSearchStore` from the Agent Framework sample, which writes and reads them as dictionaries. Uses Microsoft Foundry models. Follows the form of [Basic Text RAG](https://github.com/microsoft/agent-framework/tree/main/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG). |
| [RAG with Chroma, the TextSearchStore and Ollama](./samples/AgentWithRAG_Step07_ChromaBasicTextRAG_Ollama/) | The same sample with models that run locally in Ollama. |

The Microsoft Foundry samples need a Foundry project and `az login`; each README lists what it needs. The Ollama samples need only the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) and Docker: [compose.yaml](./compose.yaml) runs Chroma and Ollama, and downloads the models.
The Microsoft Foundry samples need a Foundry project and `az login`. Each sample README lists what it needs.

The Ollama samples need only the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) and Docker. The [compose.yaml](./compose.yaml) file runs Chroma and Ollama, and downloads the models.

```bash
docker compose up -d
Expand All @@ -32,12 +36,16 @@ dotnet run --project samples/AgentWithMemory_Step10_MemoryUsingChroma_Ollama
dotnet test
```

GitHub Actions runs them on every push to `main` and on every pull request to `main`.
GitHub Actions runs the tests on every push to `main` and on every pull request to `main`.

The tests run each sample's scenario with the same configuration as the sample. Chroma runs in a container started with [ChromaDotNet.Testcontainers](https://www.nuget.org/packages/ChromaDotNet.Testcontainers). The tests need Docker, but no model. The embeddings come from word hashes, and the chat model only records what the agent sends to it.

What the tests check:

The tests run the scenario of each sample, with the same configuration, against Chroma in a container started with [ChromaDotNet.Testcontainers](https://www.nuget.org/packages/ChromaDotNet.Testcontainers). They need Docker, but no model: the embeddings come from word hashes and the chat model only records what the agent sends to it.
- Memory: the user's preference reaches the model in a new session, and another user's messages do not. Each session is stored under its own session id.
- RAG: the chunk that answers the question reaches the model, and the search results are not stored in the chat history. A follow-up question is searched with the recent messages. The chunks are stored with their source.
- RAG with the TextSearchStore: the document that answers each question reaches the model, and the search results are not stored in the chat history. The documents are stored with their source.

- Memory: the preference of the user reaches the model in a new session, the messages of another user do not, and each session is stored under its own session id.
- RAG: the chunk that answers the question reaches the model, the search results are not stored in the chat history, a follow-up question is searched with the recent messages, and the chunks are stored with their source.
- RAG with the TextSearchStore: the document that answers each question reaches the model, the search results are not stored in the chat history, and the documents are stored with their source.
The `TextSearchStore` in [AgentWithRAG_Step07_ChromaBasicTextRAG/TextSearchStore](./samples/AgentWithRAG_Step07_ChromaBasicTextRAG/TextSearchStore/) is copied unchanged from the [Agent Framework repository](https://github.com/microsoft/agent-framework) (MIT) and keeps its copyright notice.

The `TextSearchStore` in [AgentWithRAG_Step07_ChromaBasicTextRAG/TextSearchStore](./samples/AgentWithRAG_Step07_ChromaBasicTextRAG/TextSearchStore/) comes from the [Agent Framework repository](https://github.com/microsoft/agent-framework) (MIT) as it is, and keeps its copyright notice; the programs of the samples are adaptations of the Agent Framework samples linked in the table above, under the same license, and carry the same copyright notice.
The sample programs are adaptations of the Agent Framework samples linked in the table above. They are under the same license and carry the same copyright notice.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.Identity" Version="1.21.0" />
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.5" />
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.6" />
<PackageReference Include="Microsoft.Agents.AI.Foundry" Version="1.23.0-preview.260928.1" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions samples/AgentWithMemory_Step10_MemoryUsingChroma/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Agent with Memory Using Chroma

This sample uses `ChatHistoryMemoryProvider` with `ChromaVectorStore` from [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData) to persist chat history in [Chroma](https://www.trychroma.com/) and recall relevant messages in a new agent session.
This sample persists chat history in [Chroma](https://www.trychroma.com/) and recalls relevant messages in a new agent session. It uses `ChatHistoryMemoryProvider` with `ChromaVectorStore` from [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData).

## Features Demonstrated

Expand All @@ -15,15 +15,15 @@ This sample uses `ChatHistoryMemoryProvider` with `ChromaVectorStore` from [Chro
2. A Microsoft Foundry project with:
- A chat model deployment (the default is `gpt-5.4-mini`)
- A `text-embedding-3-large` deployment with 3,072 dimensions
3. A running Chroma server, 1.5.0 or later: `docker compose up -d chroma` at the root of the repository starts the instance defined in the [compose file](../../compose.yaml), or you can run one with Docker:
3. A running Chroma server, version 1.5.0 or later. To start the instance defined in the [compose file](../../compose.yaml), run `docker compose up -d chroma` at the root of the repository. Or you can run one with Docker:

```bash
docker run -d --name chroma -p 8000:8000 chromadb/chroma:1.5.9
```

4. Azure CLI authentication (`az login`) with an identity that has the Foundry User role on the Foundry resource

The Foundry project endpoint does not serve embeddings, so the sample generates them through the endpoint of the Foundry resource that hosts the project, with the same credential.
The Foundry project endpoint does not serve embeddings. The sample generates them through the endpoint of the Foundry resource that hosts the project, using the same credential.

## Configuration

Expand All @@ -43,4 +43,4 @@ Set the following environment variables:
dotnet run
```

The first session stores the user's preference for pirate jokes. The second session uses a different `AgentSession` but the same per-run user search scope, allowing the agent to retrieve that preference from Chroma without recalling data from earlier sample runs.
The first session stores the user's preference for pirate jokes. The second session uses a different `AgentSession` but the same per-run user search scope. This lets the agent retrieve that preference from Chroma without recalling data from earlier sample runs.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.5" />
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.6" />
<PackageReference Include="Microsoft.Agents.AI" Version="1.23.0" />
<PackageReference Include="OllamaSharp" Version="5.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Agent with Memory Using Chroma and Ollama

This sample is [Agent with Memory Using Chroma](../AgentWithMemory_Step10_MemoryUsingChroma/) with models that run locally in [Ollama](https://ollama.com/) instead of Microsoft Foundry. It uses `ChatHistoryMemoryProvider` with `ChromaVectorStore` from [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData) to persist chat history in [Chroma](https://www.trychroma.com/) and recall relevant messages in a new agent session.
This sample is [Agent with Memory Using Chroma](../AgentWithMemory_Step10_MemoryUsingChroma/) with models that run locally in [Ollama](https://ollama.com/) instead of Microsoft Foundry.

It persists chat history in [Chroma](https://www.trychroma.com/) and recalls relevant messages in a new agent session. It uses `ChatHistoryMemoryProvider` with `ChromaVectorStore` from [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData).

## Features Demonstrated

Expand All @@ -18,7 +20,7 @@ This sample is [Agent with Memory Using Chroma](../AgentWithMemory_Step10_Memory
docker compose up -d
```

The first run downloads `qwen2.5:3b` and `nomic-embed-text`, about 2 GB; `docker compose logs -f ollama-models` shows the progress.
The first run downloads `qwen2.5:3b` and `nomic-embed-text` (about 2 GB). To see the progress, run `docker compose logs -f ollama-models`.

## Configuration

Expand All @@ -38,4 +40,6 @@ The defaults match the compose file. To change them, set the following environme
dotnet run
```

The first session stores the user's preference for pirate jokes. The second session uses a different `AgentSession` but the same per-run user search scope, allowing the agent to retrieve that preference from Chroma without recalling data from earlier sample runs. The chat history goes in a collection of its own, `chathistory-local`, since the local embedding model has fewer dimensions than the Foundry one.
The first session stores the user's preference for pirate jokes. The second session uses a different `AgentSession` but the same per-run user search scope. This lets the agent retrieve that preference from Chroma without recalling data from earlier sample runs.

The chat history goes in its own collection, `chathistory-local`, because the local embedding model has fewer dimensions than the Foundry one.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.Identity" Version="1.21.0" />
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.5" />
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.6" />
<PackageReference Include="Microsoft.Agents.AI.Foundry" Version="1.23.0-preview.260928.1" />
</ItemGroup>

Expand Down
12 changes: 7 additions & 5 deletions samples/AgentWithRAG_Step06_ChromaRAG/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Agent Framework Retrieval Augmented Generation (RAG) with Chroma and a custom schema

This sample demonstrates how to create and run an agent that uses Retrieval Augmented Generation (RAG) with [Chroma](https://www.trychroma.com/) as the vector store, through `ChromaVectorStore` from [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData).
This sample demonstrates how to create and run an agent that uses Retrieval Augmented Generation (RAG) with [Chroma](https://www.trychroma.com/) as the vector store. It connects to Chroma through `ChromaVectorStore` from [ChromaDotNet.VectorData](https://www.nuget.org/packages/ChromaDotNet.VectorData).
It also uses a custom schema for the documents stored in the vector store.

## Prerequisites
Expand All @@ -10,15 +10,15 @@ It also uses a custom schema for the documents stored in the vector store.
- A chat model deployment (the default is `gpt-5.4-mini`)
- A `text-embedding-3-large` deployment with 3,072 dimensions
- Azure CLI installed and authenticated (`az login`) with an identity that has the Foundry User role on the Foundry resource
- A running Chroma server, 1.5.0 or later: `docker compose up -d chroma` at the root of the repository starts the instance defined in the [compose file](../../compose.yaml), or you can run a local instance using Docker:
- A running Chroma server, version 1.5.0 or later. To start the instance defined in the [compose file](../../compose.yaml), run `docker compose up -d chroma` at the root of the repository. Or you can run a local instance using Docker:

```powershell
docker run -d --name chroma -p 8000:8000 chromadb/chroma:1.5.9
```

**Note**: The Foundry project endpoint does not serve embeddings, so the sample generates them through the endpoint of the Foundry resource that hosts the project, with the same credential.
**Note**: The Foundry project endpoint does not serve embeddings. The sample generates them through the endpoint of the Foundry resource that hosts the project, using the same credential.

**Note**: The sample keeps the chat history in an `InMemoryChatHistoryProvider`, so that the search results of the `TextSearchProvider` are not stored with it. Microsoft Foundry would otherwise store the responses and manage the conversation itself, which cannot be combined with a `ChatHistoryProvider`, so the sample turns off the storage of the responses.
**Note**: The sample keeps the chat history in an `InMemoryChatHistoryProvider`, so the `TextSearchProvider` search results are not stored with it. Otherwise, Microsoft Foundry would store the responses and manage the conversation itself. That cannot be combined with a `ChatHistoryProvider`, so the sample turns off response storage.

## Running the sample from the console

Expand Down Expand Up @@ -49,4 +49,6 @@ Or just build and run in one step:
dotnet run
```

The sample downloads two documents of the Agent Framework documentation, stores them in Chroma in chunks, and asks four questions about them. The second question, "and in Agent Framework?", only makes sense after the first one: the search includes the recent messages, so it still finds the right chunks.
The sample downloads two documents from the Agent Framework documentation and stores them in Chroma in chunks. Then it asks four questions about them.

The second question, "and in Agent Framework?", only makes sense after the first one. The search includes the recent messages, so it still finds the right chunks.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.5" />
<PackageReference Include="ChromaDotNet.VectorData" Version="0.3.6" />
<PackageReference Include="Microsoft.Agents.AI" Version="1.23.0" />
<PackageReference Include="OllamaSharp" Version="5.5.0" />
</ItemGroup>
Expand Down
Loading
Loading