Class ContextServiceClient
- Namespace
- FoundationaLLM.Common.Clients
- Assembly
- FoundationaLLM.Common.dll
Provides methods to call the FoundationaLLM Context API service.
public class ContextServiceClient : IContextServiceClient
- Inheritance
-
ContextServiceClient
- Implements
- Inherited Members
- Extension Methods
Constructors
ContextServiceClient(IOrchestrationContext, IHttpClientFactoryService, ILogger<ContextServiceClient>)
Provides methods to call the FoundationaLLM Context API service.
public ContextServiceClient(IOrchestrationContext callContext, IHttpClientFactoryService httpClientFactoryService, ILogger<ContextServiceClient> logger)
Parameters
callContext
IOrchestrationContexthttpClientFactoryService
IHttpClientFactoryServicelogger
ILogger<ContextServiceClient>
Methods
CreateCodeSession(string, string, string, string, string, string)
Calls the Context API service to create a code session.
public Task<ContextServiceResponse<CreateCodeSessionResponse>> CreateCodeSession(string instanceId, string agentName, string conversationId, string context, string endpointProvider, string language)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
agentName
stringThe name of the agent.
conversationId
stringThe conversation identifier.
context
stringThe context within the conversation in which the code session must be created (e.g., an agent tool name).
endpointProvider
stringThe name of the code session endpoint provider.
language
stringThe programming language of the code session.
Returns
- Task<ContextServiceResponse<CreateCodeSessionResponse>>
A ContextServiceResponse<T> instance where
T
is of type CreateCodeSessionResponse.
CreateFile(string, string, string, string, Stream)
public Task<ContextServiceResponse<ContextFileRecord>> CreateFile(string instanceId, string resourceRoute, string fileName, string fileContentType, Stream fileContent)
Parameters
Returns
CreateFileForAgent(string, string, string, string, Stream)
Calls the Context API service to create a file.
public Task<ContextServiceResponse<ContextFileRecord>> CreateFileForAgent(string instanceId, string agentName, string fileName, string fileContentType, Stream fileContent)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
agentName
stringThe name of the agent.
fileName
stringThe name of the file to be created.
fileContentType
stringThe content type of the file to be created.
fileContent
StreamThe binary content of the file.
Returns
- Task<ContextServiceResponse<ContextFileRecord>>
A ContextServiceResponse<T> instance where
T
is of type ContextFileRecord.
CreateFileForConversation(string, string, string, string, Stream)
Calls the Context API service to create a file.
public Task<ContextServiceResponse<ContextFileRecord>> CreateFileForConversation(string instanceId, string conversationId, string fileName, string fileContentType, Stream fileContent)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
conversationId
stringThe conversation identifier.
fileName
stringThe name of the file to be created.
fileContentType
stringThe content type of the file to be created.
fileContent
StreamThe binary content of the file.
Returns
- Task<ContextServiceResponse<ContextFileRecord>>
A ContextServiceResponse<T> instance where
T
is of type ContextFileRecord.
DeleteFileRecord(string, string)
Calls the Context API service to delete a file record.
public Task<ContextServiceResponse> DeleteFileRecord(string instanceId, string fileId)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
fileId
stringThe unique identifier of the file.
Returns
- Task<ContextServiceResponse>
A ContextServiceResponse instance .
GetFileContent(string, string)
Calls the Context API service to get the content of a file.
public Task<ContextServiceResponse<ContextFileContent>> GetFileContent(string instanceId, string fileId)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
fileId
stringThe unique identifier of the file.
Returns
- Task<ContextServiceResponse<ContextFileContent>>
A ContextServiceResponse<T> instance where
T
is of type ContextFileContent.
GetFileRecord(string, string)
Calls the Context API service to get a file record.
public Task<ContextServiceResponse<ContextFileRecord>> GetFileRecord(string instanceId, string fileId)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
fileId
stringThe unique identifier of the file.
Returns
- Task<ContextServiceResponse<ContextFileRecord>>
A ContextServiceResponse<T> instance where
T
is of type ContextFileRecord.
GetKnowledgeSource(string, string)
Call the Context API to retrieve a knowledge source.
public Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeSource>>> GetKnowledgeSource(string instanceId, string knowledgeSourceId)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeSourceId
stringThe knowledge source identifier.
Returns
- Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeSource>>>
The requested knowledge source.
GetKnowledgeSources(string, IEnumerable<string>?)
Call the Context API to retrieve the list of knowledge sources.
public Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeSource>>>> GetKnowledgeSources(string instanceId, IEnumerable<string>? knowledgeSourceNames = null)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeSourceNames
IEnumerable<string>An optional list of specific knowledge sources to retrieve.
Returns
- Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeSource>>>>
The list of knowledge sources.
GetKnowledgeUnit(string, string)
Call the Context API to retrieve the a knowledge unit.
public Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeUnit>>> GetKnowledgeUnit(string instanceId, string knowledgeUnitId)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeUnitId
stringThe knowledge unit identifier.
Returns
- Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeUnit>>>
The requested knowledge unit.
GetKnowledgeUnits(string, IEnumerable<string>?)
Call the Context API to retrieve the list of knowledge units.
public Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeUnit>>>> GetKnowledgeUnits(string instanceId, IEnumerable<string>? knowledgeUnitNames = null)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeUnitNames
IEnumerable<string>An optional list of specific knowledge units to retrieve.
Returns
- Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeUnit>>>>
The list of knowledge units.
QueryKnowledgeSource(string, string, ContextKnowledgeSourceQueryRequest)
Calls the Context API to query a knowledge source.
public Task<ContextKnowledgeSourceQueryResponse> QueryKnowledgeSource(string instanceId, string knowledgeSourceId, ContextKnowledgeSourceQueryRequest queryRequest)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeSourceId
stringThe knowledge source identifier.
queryRequest
ContextKnowledgeSourceQueryRequestThe request object containing query parameters and options.
Returns
- Task<ContextKnowledgeSourceQueryResponse>
A response containing the result of the query execution.
RenderKnowledgeUnitGraph(string, string, ContextKnowledgeSourceQueryRequest?)
Retrieves the knowledge unit's knowledge graph in a format suitable for visualization or further processing.
public Task<ContextKnowledgeUnitRenderGraphResponse> RenderKnowledgeUnitGraph(string instanceId, string knowledgeSourceId, ContextKnowledgeSourceQueryRequest? queryRequest)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeSourceId
stringqueryRequest
ContextKnowledgeSourceQueryRequestThe request containing the details of the query.
Returns
SetKnowledgeUnitGraph(string, string, ContextKnowledgeUnitSetGraphRequest)
Sets the knowledge graph for a knowledge unit.
public Task<ContextServiceResponse<ResourceProviderActionResult>> SetKnowledgeUnitGraph(string instanceId, string knowledgeUnitId, ContextKnowledgeUnitSetGraphRequest setGraphRequest)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeUnitId
stringThe knowledge unit identifier.
setGraphRequest
ContextKnowledgeUnitSetGraphRequestThe request containing the knowledge graph details.
Returns
- Task<ContextServiceResponse<ResourceProviderActionResult>>
A response indicating the success of the operation and an optional error message.
UpsertKnowledgeSource(string, KnowledgeSource)
Creates or updates a knowledge source in the context service.
public Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeSource>>> UpsertKnowledgeSource(string instanceId, KnowledgeSource knowledgeSource)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeSource
KnowledgeSourceThe knowledge source resource to be created or updated.
Returns
UpsertKnowledgeUnit(string, KnowledgeUnit)
Creates or updates a knowledge unit in the context service.
public Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeUnit>>> UpsertKnowledgeUnit(string instanceId, KnowledgeUnit knowledgeUnit)
Parameters
instanceId
stringThe FoundationaLLM instance identifier.
knowledgeUnit
KnowledgeUnitThe knowledge unit resource to be created or updated.