Table of Contents

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 IOrchestrationContext
httpClientFactoryService IHttpClientFactoryService
logger 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 string

The FoundationaLLM instance identifier.

agentName string

The name of the agent.

conversationId string

The conversation identifier.

context string

The context within the conversation in which the code session must be created (e.g., an agent tool name).

endpointProvider string

The name of the code session endpoint provider.

language string

The 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

instanceId string
resourceRoute string
fileName string
fileContentType string
fileContent Stream

Returns

Task<ContextServiceResponse<ContextFileRecord>>

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 string

The FoundationaLLM instance identifier.

agentName string

The name of the agent.

fileName string

The name of the file to be created.

fileContentType string

The content type of the file to be created.

fileContent Stream

The 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 string

The FoundationaLLM instance identifier.

conversationId string

The conversation identifier.

fileName string

The name of the file to be created.

fileContentType string

The content type of the file to be created.

fileContent Stream

The 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 string

The FoundationaLLM instance identifier.

fileId string

The 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 string

The FoundationaLLM instance identifier.

fileId string

The 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 string

The FoundationaLLM instance identifier.

fileId string

The 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 string

The FoundationaLLM instance identifier.

knowledgeSourceId string

The 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 string

The 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 string

The FoundationaLLM instance identifier.

knowledgeUnitId string

The 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 string

The 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 string

The FoundationaLLM instance identifier.

knowledgeSourceId string

The knowledge source identifier.

queryRequest ContextKnowledgeSourceQueryRequest

The 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 string

The FoundationaLLM instance identifier.

knowledgeSourceId string
queryRequest ContextKnowledgeSourceQueryRequest

The request containing the details of the query.

Returns

Task<ContextKnowledgeUnitRenderGraphResponse>

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 string

The FoundationaLLM instance identifier.

knowledgeUnitId string

The knowledge unit identifier.

setGraphRequest ContextKnowledgeUnitSetGraphRequest

The 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 string

The FoundationaLLM instance identifier.

knowledgeSource KnowledgeSource

The knowledge source resource to be created or updated.

Returns

Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeSource>>>

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 string

The FoundationaLLM instance identifier.

knowledgeUnit KnowledgeUnit

The knowledge unit resource to be created or updated.

Returns

Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeUnit>>>