I have semantic kernel
Open AI configuration that uses chromadb
.
// Initialization
var collectionName = "mydataMemory";
await chromaClient.CreateCollectionAsync(collectionName, cancellationToken);
// Save records
var chromaMemoryStore = new ChromaMemoryStore(chromaClient);
var memory = new SemanticTextMemory(chromaMemoryStore, textEmbeddingGenerationService);
await memory.SaveInformationAsync(collectionName, text, id, description, metadata, cancellationToken: cancellationToken);
`metadata` and `description` are always empty for now.
locally when I spawn chromadb
in this way:
chroma run --host localhost --port 8000
all works fine, but when I configure it on the docker compose
, I see the following error:
chroma_server-1 | INFO: [23-02-2025] - "POST /api/v1/collections HTTP/1.1" 200
myapp-1 | info: Microsoft.SemanticKernel.Connectors.OpenAI.OpenAITextEmbeddingGenerationService[0]
myapp-1 | Action: GenerateEmbeddingsAsync. OpenAI Model ID: text-embedding-ada-002.
chroma_server-1 | INFO: [23-02-2025 - "GET /api/v1/collections/mydataMemory HTTP/1.1" 400
myapp-1 | fail: Microsoft.Extensions.Hosting.Internal.Host[9]
myapp-1 | BackgroundService failed
myapp-1 | Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 400 (Bad Request).
myapp-1 | ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
myapp-1 | at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
myapp-1 | --- End of inner exception stack trace ---
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaClient.ExecuteHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaClient.GetCollectionAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaMemoryStore.GetCollectionAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaMemoryStore.DoesCollectionExistAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SaveInformationAsync(String collection, String text, String id, String description, String additionalMetadata, Kernel kernel, CancellationToken cancellationToken)
myapp-1 | at AiTool.SemanticKernel.ChromaDb.MemoryClient.Save(MemoryCollection collection, String text, String id, String description, String metadata, CancellationToken cancellationToken) in /src/AiTool.SemanticKernel.ChromaDb/MemoryClient.cs:line 27
myapp-1 | at myapp.mydataPlugin.Initializemydata() in /src/myapp/Plugins/mydataPlugin.cs:line 33
myapp-1 | at myapp.AiBotInitializer.Initialize() in /src/myapp/AiBotBootstrapper.cs:line 25
myapp-1 | at myapp.Worker.ExecuteAsync(CancellationToken stoppingToken) in /src/myapp/Worker.cs:line 39
myapp-1 | at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
myapp-1 | crit: Microsoft.Extensions.Hosting.Internal.Host[10]
myapp-1 | The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
myapp-1 | Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 400 (Bad Request).
myapp-1 | ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
myapp-1 | at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
myapp-1 | --- End of inner exception stack trace ---
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaClient.ExecuteHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaClient.GetCollectionAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaMemoryStore.GetCollectionAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaMemoryStore.DoesCollectionExistAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SaveInformationAsync(String collection, String text, String id, String description, String additionalMetadata, Kernel kernel, CancellationToken cancellationToken)
myapp-1 | at AiTool.SemanticKernel.ChromaDb.MemoryClient.Save(MemoryCollection collection, String text, String id, String description, String metadata, CancellationToken cancellationToken) in /src/AiTool.SemanticKernel.ChromaDb/MemoryClient.cs:line 27
myapp-1 | at myapp.mydataPlugin.Initializemydata() in /src/myapp/Plugins/mydataPlugin.cs:line 33
myapp-1 | at myapp.AiBotInitializer.Initialize() in /src/myapp/AiBotBootstrapper.cs:line 25
myapp-1 | at myapp.Worker.ExecuteAsync(CancellationToken stoppingToken) in /src/myapp/Worker.cs:line 39
myapp-1 | at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
where docker compose file is:
version: '3.9'
networks:
net:
driver: bridge
services:
chroma_server:
image: chromadb/chroma:latest
volumes:
- chroma-data:/chroma/chroma
restart: unless-stopped # possible values are: "no", always", "on-failure", "unless-stopped"
ports:
- "8000:8000"
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8000/api/v2/heartbeat" ]
interval: 30s
timeout: 10s
retries: 3
networks:
- net
myapp:
image: ${DOCKER_REGISTRY-}myapp
build:
context: .
dockerfile: myapp/Dockerfile
depends_on:
chroma_server:
condition: service_healthy
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- MyApp_API_KEY=${MyApp_API_KEY}
networks:
- net
volumes:
chroma-data:
driver: local
Few notes:
localhost:8000
chroma
endpoint is replaced on http://chroma_server:8000
in the docker myapp
env.Any help would be appreciated.
UPDATE1:
Log after renaming chroma_server
to chroma
in docker compose:
Pull complete
chroma Pulled
Network bot_net Creating
Network bot_net Created
Volume "bot_chroma-data" Creating
Volume "bot_chroma-data" Created
Container bot-chroma-1 Creating
Container bot-chroma-1 Created
Container bot-myapp-1 Creating
Container bot-myapp-1 Created
Attaching to chroma-1, telegrambot-1
chroma-1 | Starting 'uvicorn chromadb.app:app' with args: --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
chroma-1 | WARNING: [01-03-2025 14:09:54] chroma_server_nofile is set to 65536, but this is less than current soft limit of 1048576. chroma_server_nofile will not be set.
chroma-1 | INFO: [01-03-2025 14:09:55] Anonymized telemetry enabled. See https://docs.trychroma.com/telemetry for more information.
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component System
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component OpenTelemetryClient
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component SqliteDB
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component SimpleQuotaEnforcer
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component Posthog
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component SimpleRateLimitEnforcer
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component LocalSegmentManager
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component LocalExecutor
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component SegmentAPI
chroma-1 | DEBUG: [01-03-2025 14:09:55] Starting component SimpleAsyncRateLimitEnforcer
chroma-1 | INFO: [01-03-2025 14:09:55] Started server process [1]
chroma-1 | INFO: [01-03-2025 14:09:55] Waiting for application startup.
chroma-1 | INFO: [01-03-2025 14:09:55] Application startup complete.
chroma-1 | INFO: [01-03-2025 14:09:55] Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
chroma-1 | INFO: [01-03-2025 14:10:23] 127.0.0.1:37884 - "GET /api/v2/heartbeat HTTP/1.1" 200
myapp-1 | info: Microsoft.Hosting.Lifetime[0]
myapp-1 | Application started. Press Ctrl+C to shut down.
myapp-1 | info: Microsoft.Hosting.Lifetime[0]
myapp-1 | Hosting environment: Production
myapp-1 | info: Microsoft.Hosting.Lifetime[0]
myapp-1 | Content root path: /app
myapp-1 | info: TelegramBot.Worker[0]
myapp-1 | Bot Id: 1234567890, Bot Name: ai_bot
myapp-1 | info: TelegramBot.Worker[0]
myapp-1 | Telegram Bot started.
chroma-1 | INFO: [01-03-2025 ..] 172.X.Y.Z:12345 - "POST /api/v1/collections HTTP/1.1" 200
myapp-1 | info: Microsoft.SemanticKernel.Connectors.OpenAI.OpenAITextEmbeddingGenerationService[0]
myapp-1 | Action: GenerateEmbeddingsAsync. OpenAI Model ID: text-embedding-ada-002.
chroma-1 | INFO: [01-03-2025 ..] 172.X.Y.Z:12345 - "GET /api/v1/collections/myDataMemory HTTP/1.1" 400
myapp-1 | fail: Microsoft.Extensions.Hosting.Internal.Host[9]
myapp-1 | BackgroundService failed
myapp-1 | Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 400 (Bad Request).
myapp-1 | ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
myapp-1 | at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
myapp-1 | --- End of inner exception stack trace ---
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaClient.ExecuteHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaClient.GetCollectionAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaMemoryStore.GetCollectionAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Connectors.Chroma.ChromaMemoryStore.DoesCollectionExistAsync(String collectionName, CancellationToken cancellationToken)
myapp-1 | at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SaveInformationAsync(String collection, String text, String id, String description, String additionalMetadata, Kernel kernel, CancellationToken cancellationToken)
..
Thanks @Fahmi Noor Fiqri. After configuring additional output, I noticed that actual error is: {"error":"InvalidArgumentError","message":"cannot unpack non-iterable coroutine object"}
. After quick googling, I found that it's a bug in chroma image: https://github.com/chroma-core/chroma/issues/3798. The solution will be in the version 0.6.4
, a stable version of it is not available yet. The prerelease version 0.6.4.dev283
solves the issue too