Class CoreClient
- Namespace
- FoundationaLLM.Client.Core
- Assembly
- FoundationaLLM.Client.Core.dll
Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
public class CoreClient : ICoreClient
- Inheritance
-
CoreClient
- Implements
- Inherited Members
- Extension Methods
Constructors
CoreClient()
Constructor for mocking. This does not initialize the clients.
public CoreClient()
CoreClient(string, TokenCredential, string)
Initializes a new instance of the CoreClient class with the specified Core API URI and TokenCredential.
public CoreClient(string coreUri, TokenCredential credential, string instanceId)
Parameters
coreUristringThe base URI of the Core API.
credentialTokenCredentialA TokenCredential of an authenticated user or service principle from which the client library can generate auth tokens.
instanceIdstringThe unique (GUID) ID for the FoundationaLLM deployment. Locate this value in the FoundationaLLM Management Portal or in Azure App Config (FoundationaLLM:Instance:Id key)
CoreClient(string, TokenCredential, string, APIClientSettings)
Initializes a new instance of the CoreClient class with the specified Core API URI, TokenCredential, and optional client settings.
public CoreClient(string coreUri, TokenCredential credential, string instanceId, APIClientSettings options)
Parameters
coreUristringThe base URI of the Core API.
credentialTokenCredentialA TokenCredential of an authenticated user or service principle from which the client library can generate auth tokens.
instanceIdstringThe unique (GUID) ID for the FoundationaLLM deployment. Locate this value in the FoundationaLLM Management Portal or in Azure App Config (FoundationaLLM:Instance:Id key)
optionsAPIClientSettingsAdditional options to configure the HTTP Client.
CoreClient(string, ApiKeyCredential, string)
Initializes a new instance of the CoreClient class with the specified Core API URI and API key credential.
public CoreClient(string coreUri, ApiKeyCredential credential, string instanceId)
Parameters
coreUristringThe base URI of the Core API.
credentialApiKeyCredentialAn System.ClientModel.ApiKeyCredential containing a valid agent access token.
instanceIdstringThe unique (GUID) ID for the FoundationaLLM deployment. Locate this value in the FoundationaLLM Management Portal or in Azure App Config (FoundationaLLM:Instance:Id key)
CoreClient(string, ApiKeyCredential, string, APIClientSettings)
Initializes a new instance of the CoreClient class with the specified Core API URI, API key credential, and optional client settings.
public CoreClient(string coreUri, ApiKeyCredential credential, string instanceId, APIClientSettings options)
Parameters
coreUristringThe base URI of the Core API.
credentialApiKeyCredentialAn System.ClientModel.ApiKeyCredential containing a valid agent access token.
instanceIdstringThe unique (GUID) ID for the FoundationaLLM deployment. Locate this value in the FoundationaLLM Management Portal or in Azure App Config (FoundationaLLM:Instance:Id key)
optionsAPIClientSettingsAdditional options to configure the HTTP Client.
Methods
AttachFileAndAskQuestionAsync(Stream, string, string, string, string, bool, string?, ConversationProperties?)
Attaches a file to the completion request and sends a question to the agent using the Core API.If the useSession parameter is true, the method uses an existing session or creates a new chat session and optionally renames it. existing session
public Task<Message> AttachFileAndAskQuestionAsync(Stream fileStream, string fileName, string contentType, string agentName, string question, bool useSession, string? sessionId, ConversationProperties? chatSessionProperties)
Parameters
fileStreamStreamThe file contents of the new Attachment resource.
fileNamestringThe name of the file.
contentTypestringThe Content-Type header value of a valid mime type that is used to create a new MediaTypeHeaderValue as part of the MultipartFormDataContent sent to the API endpoint.
agentNamestringThe name of the FoundationaLLM agent that will handle the completion request.
questionstringThe user prompt to send to the agent along with the attachment.
useSessionboolIf true, the completion is sent to a new or existing session. If false, no session is created and the sessionless orchestration flow is used.
sessionIdstringThe ID of an existing session. If null or empty, a new session is created first.
chatSessionPropertiesConversationPropertiesOptional session properties.
Returns
CreateChatSessionAsync(ConversationProperties)
Creates a new chat session with the specified name.
public Task<string> CreateChatSessionAsync(ConversationProperties chatSessionProperties)
Parameters
chatSessionPropertiesConversationProperties
Returns
DeleteSessionAsync(string)
Deletes a chat session.
public Task DeleteSessionAsync(string sessionId)
Parameters
sessionIdstringThe ID of the session to delete.
Returns
GetAgentsAsync()
Retrieves agents available to the user for orchestration and session-based requests.
public Task<IEnumerable<ResourceProviderGetResult<AgentBase>>> GetAgentsAsync()
Returns
- Task<IEnumerable<ResourceProviderGetResult<AgentBase>>>
A list of available agents.
GetChatSessionMessagesAsync(string)
Returns the chat messages related to an existing session.
public Task<IEnumerable<Message>> GetChatSessionMessagesAsync(string sessionId)
Parameters
sessionIdstring
Returns
GetCompletionAsync(CompletionRequest)
Runs a single completion with an agent using the Core API without a chat session (sessionless). This method sends a user prompt to the agent and returns the completion response. You must ensure that the completion request contains an AgentName and UserPrompt.
public Task<Message> GetCompletionAsync(CompletionRequest completionRequest)
Parameters
completionRequestCompletionRequestThe orchestration request that contains the AgentName and UserPrompt at a minimum.
Returns
GetCompletionAsync(string, string)
Runs a single completion with an agent using the Core API without a chat session (sessionless). This method sends a user prompt to the agent and returns the completion response.
public Task<Message> GetCompletionAsync(string userPrompt, string agentName)
Parameters
userPromptstringThe user prompt to send to the agent.
agentNamestringThe name of the FoundationaLLM agent that will handle the completion request.
Returns
GetCompletionWithSessionAsync(CompletionRequest)
Runs a single completion request with an agent using the Core API and a chat session. You must ensure that the orchestration request contains a SessionID, AgentName, and UserPrompt.
public Task<Message> GetCompletionWithSessionAsync(CompletionRequest completionRequest)
Parameters
completionRequestCompletionRequestThe orchestration request that contains the SessionID, AgentName, and UserPrompt at a minimum.
Returns
GetCompletionWithSessionAsync(string?, ConversationProperties?, string, string)
Runs a single completion request with an agent using the Core API and a chat session. To specify an existing session, provide the session ID. Otherwise, a new session will be created. If the session name is provided, the session is renamed.
public Task<Message> GetCompletionWithSessionAsync(string? sessionId, ConversationProperties? chatSessionProperties, string userPrompt, string agentName)
Parameters
sessionIdstringThe ID of an existing session. If null or empty, a new session is created first.
chatSessionPropertiesConversationPropertiesuserPromptstringThe user prompt to send to the agent.
agentNamestringThe name of the FoundationaLLM agent that will handle the completion request.
Returns
RateMessageAsync(string, string, MessageRatingRequest)
Sets the rating for a message.
public Task RateMessageAsync(string sessionId, string messageId, MessageRatingRequest rating)
Parameters
sessionIdstringThe chat session ID that contains the message to rate.
messageIdstringThe ID of the message to rate.
ratingMessageRatingRequestThe rating and optional comments to assign to the message.