Table of Contents

Class SessionsController

Namespace
FoundationaLLM.Core.API.Controllers
Assembly
FoundationaLLM.Core.API.dll

Provides methods for retrieving and managing sessions.

[Authorize(AuthenticationSchemes = "Bearer", Policy = "MicrosoftEntraIDStandard")]
[Authorize(AuthenticationSchemes = "AgentAccessToken", Policy = "FoundationaLLMAgentAccessToken")]
[ApiController]
[Route("instances/{instanceId}/[controller]")]
public class SessionsController : ControllerBase
Inheritance
SessionsController
Inherited Members
Extension Methods

Remarks

Constructor for the Sessions Controller.

Constructors

SessionsController(ICoreService, ILogger<SessionsController>)

Provides methods for retrieving and managing sessions.

public SessionsController(ICoreService coreService, ILogger<SessionsController> logger)

Parameters

coreService ICoreService

The Core service provides methods for managing chat sessions and messages, and for getting completions from the orchestrator.

logger ILogger<SessionsController>

The logging interface used to log under the SessionsController type name.

Remarks

Constructor for the Sessions Controller.

Methods

CreateNewChatSession(string, ChatSessionProperties)

Creates a new chat session.

[HttpPost(Name = "CreateNewChatSession")]
public Task<Conversation> CreateNewChatSession(string instanceId, ChatSessionProperties chatSessionProperties)

Parameters

instanceId string

The id of the instance.

chatSessionProperties ChatSessionProperties

The session properties.

Returns

Task<Conversation>

DeleteChatSession(string, string)

Delete a chat session and related messages.

[HttpDelete("{sessionId}", Name = "DeleteChatSession")]
public Task DeleteChatSession(string instanceId, string sessionId)

Parameters

instanceId string

The id of the instance.

sessionId string

The session id to delete.

Returns

Task

GetAllChatSessions(string)

Returns list of chat session ids and names.

[HttpGet(Name = "GetAllChatSessions")]
public Task<IEnumerable<Conversation>> GetAllChatSessions(string instanceId)

Parameters

instanceId string

The id of the instance.

Returns

Task<IEnumerable<Conversation>>

GetChatSessionMessages(string, string)

Returns the chat messages related to an existing session.

[HttpGet("{sessionId}/messages", Name = "GetChatSessionMessages")]
public Task<IEnumerable<Message>> GetChatSessionMessages(string instanceId, string sessionId)

Parameters

instanceId string

The id of the instance.

sessionId string

The id of the session for which to retrieve chat messages.

Returns

Task<IEnumerable<Message>>

GetCompletionPrompt(string, string, string)

Returns the completion prompt for a given session and completion prompt id.

[HttpGet("{sessionId}/completionprompts/{completionPromptId}", Name = "GetCompletionPrompt")]
public Task<CompletionPrompt> GetCompletionPrompt(string instanceId, string sessionId, string completionPromptId)

Parameters

instanceId string

The id of the instance.

sessionId string

The session id from which to retrieve the completion prompt.

completionPromptId string

The id of the completion prompt to retrieve.

Returns

Task<CompletionPrompt>

RateMessage(string, string, string, MessageRatingRequest)

Rate an assistant message. This can be used to discover useful AI responses for training, discoverability, and other benefits down the road.

[HttpPost("{sessionId}/message/{messageId}/rate", Name = "RateMessage")]
public Task RateMessage(string instanceId, string messageId, string sessionId, MessageRatingRequest ratingRequest)

Parameters

instanceId string

The id of the instance.

messageId string

The id of the message to rate.

sessionId string

The id of the session to which the message belongs.

ratingRequest MessageRatingRequest

The rating and optional comments to assign to the message.

Returns

Task

RenameChatSession(string, string, ChatSessionProperties)

Rename the chat session.

[HttpPost("{sessionId}/rename", Name = "RenameChatSession")]
public Task<Conversation> RenameChatSession(string instanceId, string sessionId, ChatSessionProperties chatSessionProperties)

Parameters

instanceId string

The id of the instance.

sessionId string

The id of the session to rename.

chatSessionProperties ChatSessionProperties

The session properties.

Returns

Task<Conversation>