Skip to content

Chroma .NET SaveInformationAsync is not idempotent #1783

@dluc

Description

@dluc

Describe the bug

When saving a record multiple times using SaveInformationAsync the connector throws an exception if the record already exists, rather than just overwrite.

To Reproduce
Steps to reproduce the behavior:

  1. Start from notebook: https://github.com/microsoft/semantic-kernel/blob/main/samples/notebooks/dotnet/06-memory-and-embeddings.ipynb
  2. Change from VolatileMemoryStore to ChromaMemoryStore
  3. Run the notebook twice
  4. See error

Expected behavior

One should be able to run the notebook multiple times, e.g. memory records should be updated when they already exist.

Screenshots

Error: Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaClientException: POST collections/443a09ec-c1de-43e1-92a8-7ee5c61a9739/add operation failed: Response status code does not indicate success: 409 (Conflict)., {"error":"IDAlreadyExists","message":"IDs ['info1'] already exist in collection 443a09ec-c1de-43e1-92a8-7ee5c61a9739"}
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 409 (Conflict).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaClient.ExecuteHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaClient.ExecuteHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaClient.AddEmbeddingsAsync(String collectionId, String[] ids, Single[][] embeddings, Object[] metadatas, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaMemoryStore.UpsertBatchAsync(String collectionName, IEnumerable`1 records, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaMemoryStore.UpsertBatchAsync(String collectionName, IEnumerable`1 records, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at System.Linq.AsyncEnumerable.FirstOrDefaultAsync[T](IAsyncEnumerable`1 source, CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.FirstOrDefaultAsync[T](IAsyncEnumerable`1 source, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Connectors.Memory.Chroma.ChromaMemoryStore.UpsertAsync(String collectionName, MemoryRecord record, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SaveInformationAsync(String collection, String text, String id, String description, String additionalMetadata, CancellationToken cancellationToken)
at Submission#25.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)

Desktop (please complete the following information):

  • OS: Mac
  • IDE: VSCode
  • NuGet Package Version: 0.17.230629.1-preview

Additional context

Running Chroma locally via docker-compose up --build

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codeai connectorAnything related to AI connectorsmemory connectorsk team issueA tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)

    Type

    No type

    Projects

    Status

    Sprint: Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions