Code: Select all
// 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.
Code: Select all
chroma run --host localhost --port 8000
Code: Select all
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)
< /code>
wobei die Docker -Komponierungsdatei: < /p>
lautet 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
[*] Wie ich oben geschrieben habe, funktioniert der Code lokal (ohne Container)
[*] Der Localhost: 8000 Chroma endpoint wird auf http: // chroma> cocoma> in dem docer myApp ersetzt: // chroma_server: 8000 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)
..
[/code]