Class SemanticCacheService
- Namespace
- FoundationaLLM.Orchestration.Core.Services
- Assembly
- FoundationaLLM.Orchestration.Core.dll
Provides a service for managing the semantic cache.
public class SemanticCacheService : ISemanticCacheService
- Inheritance
-
SemanticCacheService
- Implements
- Inherited Members
- Extension Methods
Constructors
SemanticCacheService(IAzureCosmosDBService, IEnumerable<IResourceProviderService>, IConfiguration, ILogger<SemanticCacheService>)
Initializes a new instance of the SemanticCacheService class.
public SemanticCacheService(IAzureCosmosDBService cosmosDBService, IEnumerable<IResourceProviderService> resourceProviderServices, IConfiguration configuration, ILogger<SemanticCacheService> logger)
Parameters
cosmosDBService
IAzureCosmosDBServiceThe IAzureCosmosDBService service providing access to the Cosmos DB vector store.
resourceProviderServices
IEnumerable<IResourceProviderService>A list of IResourceProviderService resource providers hashed by resource provider name.
configuration
IConfigurationThe IConfiguration used to retrieve app settings from configuration.
logger
ILogger<SemanticCacheService>The logger used for logging..
Methods
GetCompletionResponseFromCache(string, string, CompletionRequest)
Tries to get a CompletionResponse from the semantic cache for the specified agent in the specified FoundationaLLM instance.
public Task<CompletionResponse?> GetCompletionResponseFromCache(string instanceId, string agentName, CompletionRequest completionRequest)
Parameters
instanceId
stringThe unique identifier of the FoundationaLLM instance.
agentName
stringThe name of the agent.
completionRequest
CompletionRequestThe CompletionRequest for which to get the cache item.
Returns
- Task<CompletionResponse>
A CompletionResponse if a match exists.
HasCacheForAgent(string, string)
Determines whether the semantic cache for the specified agent in the specified FoundationaLLM instance exists.
public bool HasCacheForAgent(string instanceId, string agentName)
Parameters
instanceId
stringThe unique identifier of the FoundationaLLM instance.
agentName
stringThe name of the agent.
Returns
- bool
if the semantic cache for the specified agent exists, otherwise.
InitializeCacheForAgent(string, string, AgentSemanticCacheSettings)
Initializes the semantic cache for the specified agent in the specified FoundationaLLM instance.
public Task InitializeCacheForAgent(string instanceId, string agentName, AgentSemanticCacheSettings agentSettings)
Parameters
instanceId
stringThe unique identifier of the FoundationaLLM instance.
agentName
stringThe name of the agent.
agentSettings
AgentSemanticCacheSettingsThe AgentSemanticCacheSettings providing the agent's semantic cache settings.
Returns
ResetCacheForAgent(string, string)
Resets the semantic cache for the specified agent in the specified FoundationaLLM instance.
public Task ResetCacheForAgent(string instanceId, string agentName)
Parameters
instanceId
stringThe unique identifier of the FoundationaLLM instance.
agentName
stringThe name of the agent.
Returns
SetCompletionResponseInCache(string, string, CompletionResponse)
Sets a CompletionResponse in the semantic cache for the specified agent in the specified FoundationaLLM instance.
public Task SetCompletionResponseInCache(string instanceId, string agentName, CompletionResponse completionResponse)
Parameters
instanceId
stringThe unique identifier of the FoundationaLLM instance.
agentName
stringThe name of the agent.
completionResponse
CompletionResponseThe CompletionResponse to be set in the agent's cache.