Skip to content

[API Proposal]: Add 'AdditionalCacheKeyItems' property to DistributedCachingChatClient and DistributedCachingEmbeddingGenerator #6550

@darthtrevino

Description

@darthtrevino

Background and motivation

For our work on GraphRag internally, we normally use the model-name as part of our cache key in our Python-based codebases since different models will yield dramatically different results.

It appears that there's already a mechanism where the DistributedCachingChatClient and DistributedCachingEmbeddingGenerator can be configured by users: via the configure argument within UseDistributedCache. So this can just be a property on the client classes that's visible to developers.

API Proposal (Microsoft.Extensions.AI)

class Test {
  public void test() {
    string modelName = "gpt-4o";
    ChatClientBuilder builder = createChatClientBuilder()
       .UseDistributedCache(configure: options =>
        {
            options.AdditionalCacheKeys = [modelName]
        });
  }
}

API Usage

See example above

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

Labels

api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-aiMicrosoft.Extensions.AI libraries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions