Table of Contents

Class KnowledgeService

Namespace
FoundationaLLM.Context.Services
Assembly
FoundationaLLM.ContextEngine.dll

Provides the implementation for the FoundationaLLM Knowledge Graph service.

public class KnowledgeService : IKnowledgeService
Inheritance
KnowledgeService
Implements
Inherited Members
Extension Methods

Constructors

KnowledgeService(IStorageService, IAuthorizationServiceClient, IResourceProviderService, IResourceProviderService, IResourceProviderService, IHttpClientFactoryService, KnowledgeServiceSettings, ILoggerFactory)

Provides the implementation for the FoundationaLLM Knowledge Graph service.

public KnowledgeService(IStorageService storageService, IAuthorizationServiceClient authorizationServiceClient, IResourceProviderService contextResourceProvider, IResourceProviderService configurationResourceProvider, IResourceProviderService vectorResourceProvider, IHttpClientFactoryService httpClientFactory, KnowledgeServiceSettings settings, ILoggerFactory loggerFactory)

Parameters

storageService IStorageService

The IStorageService providing storage services.

authorizationServiceClient IAuthorizationServiceClient

The client for the FoundationaLLM Authorization API.

contextResourceProvider IResourceProviderService

The FoundationaLLM.Context resource provider service.

configurationResourceProvider IResourceProviderService

The FoundationaLLM.Configuration resource provider service.

vectorResourceProvider IResourceProviderService

The FoundationaLLM.Vector resource provider service.

httpClientFactory IHttpClientFactoryService

The factory for creating HTTP clients.

settings KnowledgeServiceSettings

The settings for the Knowledge Graph service.

loggerFactory ILoggerFactory

The logger factory used to create loggers.

Methods

GetKnowledgeSource(string, string, UnifiedUserIdentity)

Retrieves a specified knowledge source.

public Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeSource>>> GetKnowledgeSource(string instanceId, string knowledgeSourceId, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeSourceId string

The knowledge source identifier.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeSource>>>

GetKnowledgeSources(string, ContextKnowledgeResourceListRequest, UnifiedUserIdentity)

Retrieves the list of knowledge sources.

public Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeSource>>>> GetKnowledgeSources(string instanceId, ContextKnowledgeResourceListRequest listRequest, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

listRequest ContextKnowledgeResourceListRequest

The request containing the information used to filter the knowledge resources.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeSource>>>>

GetKnowledgeUnit(string, string, UnifiedUserIdentity)

Retrieves a specified knowledge unit.

public Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeUnit>>> GetKnowledgeUnit(string instanceId, string knowledgeUnitId, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeUnitId string

The knowledge unit identifier.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<ResourceProviderGetResult<KnowledgeUnit>>>

GetKnowledgeUnits(string, ContextKnowledgeResourceListRequest, UnifiedUserIdentity)

Retrieves the list of knowledge units.

public Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeUnit>>>> GetKnowledgeUnits(string instanceId, ContextKnowledgeResourceListRequest listRequest, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

listRequest ContextKnowledgeResourceListRequest

The request containing the information used to filter the knowledge resources.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<IEnumerable<ResourceProviderGetResult<KnowledgeUnit>>>>

QueryKnowledgeSource(string, string, ContextKnowledgeSourceQueryRequest, UnifiedUserIdentity)

Queries a knowledge source.

public Task<ContextKnowledgeSourceQueryResponse> QueryKnowledgeSource(string instanceId, string knowledgeSourceId, ContextKnowledgeSourceQueryRequest queryRequest, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeSourceId string

The knowledge source identifier.

queryRequest ContextKnowledgeSourceQueryRequest

The request containing the details of the query.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextKnowledgeSourceQueryResponse>

RenderKnowledgeUnitGraph(string, string, ContextKnowledgeSourceQueryRequest?, UnifiedUserIdentity)

Retrieves the knowledge unit's knowledge graph in a format suitable for visualization or further processing.

public Task<ContextKnowledgeUnitRenderGraphResponse> RenderKnowledgeUnitGraph(string instanceId, string knowledgeUnitId, ContextKnowledgeSourceQueryRequest? queryRequest, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeUnitId string

The knowledge unit identifier.

queryRequest ContextKnowledgeSourceQueryRequest

The request containing the details of the query.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextKnowledgeUnitRenderGraphResponse>

SetKnowledgeUnitGraph(string, string, ContextKnowledgeUnitSetGraphRequest, UnifiedUserIdentity)

Sets the knowledge graph associated with a knowledge unit.

public Task<ContextServiceResponse<ResourceProviderActionResult>> SetKnowledgeUnitGraph(string instanceId, string knowledgeUnitId, ContextKnowledgeUnitSetGraphRequest setGraphRequest, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeUnitId string

The knowledge unit identifier.

setGraphRequest ContextKnowledgeUnitSetGraphRequest

The request containing the knowledge graph details.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<ResourceProviderActionResult>>

UpsertKnowledgeSource(string, KnowledgeSource, UnifiedUserIdentity)

Creates or updates a knowledge source in the context service.

public Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeSource>>> UpsertKnowledgeSource(string instanceId, KnowledgeSource knowledgeSource, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeSource KnowledgeSource

The knowledge source to be created or updated.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeSource>>>

UpsertKnowledgeUnit(string, KnowledgeUnit, UnifiedUserIdentity)

Creates or updates a knowledge unit in the context service.

public Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeUnit>>> UpsertKnowledgeUnit(string instanceId, KnowledgeUnit knowledgeUnit, UnifiedUserIdentity userIdentity)

Parameters

instanceId string

The FoundationaLLM instance identifier.

knowledgeUnit KnowledgeUnit

The knowledge unit to be created or updated.

userIdentity UnifiedUserIdentity

The identity of the security principal submitting the request.

Returns

Task<ContextServiceResponse<ResourceProviderUpsertResult<KnowledgeUnit>>>