Class CodeSessionService
- Namespace
- FoundationaLLM.Context.Services
- Assembly
- FoundationaLLM.ContextEngine.dll
Implements the FoundationaLLM Code Session service.
public class CodeSessionService : ICodeSessionService
- Inheritance
-
CodeSessionService
- Implements
- Inherited Members
- Extension Methods
Constructors
CodeSessionService(IFileService, IAzureCosmosDBCodeSessionService, IEnumerable<ICodeSessionProviderService>, IResourceValidatorFactory, ILogger<CodeSessionService>)
Implements the FoundationaLLM Code Session service.
public CodeSessionService(IFileService fileService, IAzureCosmosDBCodeSessionService cosmosDBService, IEnumerable<ICodeSessionProviderService> codeSessionProviderServices, IResourceValidatorFactory resourceValidatorFactory, ILogger<CodeSessionService> logger)
Parameters
fileServiceIFileServiceThe file service used for file operations.
cosmosDBServiceIAzureCosmosDBCodeSessionServiceThe Azure Cosmos DB service providing database services.
codeSessionProviderServicesIEnumerable<ICodeSessionProviderService>The code session provider services.
resourceValidatorFactoryIResourceValidatorFactoryThe resource validator factory.
loggerILogger<CodeSessionService>The logger used for logging.
Methods
CreateCodeSession(string, CreateCodeSessionRequest, UnifiedUserIdentity)
Creates a new code session using one of the registered code session providers.
public Task<Result<CreateCodeSessionResponse>> CreateCodeSession(string instanceId, CreateCodeSessionRequest codeSessionRequest, UnifiedUserIdentity userIdentity)
Parameters
instanceIdstringThe unique identifier of the FoundationaLLM instance.
codeSessionRequestCreateCodeSessionRequestThe CreateCodeSessionRequest providing the details of the request to create the code session.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity providing the user identity information.
Returns
- Task<Result<CreateCodeSessionResponse>>
A Task producing a Result<T> whose value is a CreateCodeSessionResponse on success; otherwise a failed Result<T> with a domain error.
DownloadFilesFromCodeSession(string, string, string, UnifiedUserIdentity)
Downloads newly created files from a code session.
public Task<Result<CodeSessionFileDownloadResponse>> DownloadFilesFromCodeSession(string instanceId, string sessionId, string operationId, UnifiedUserIdentity userIdentity)
Parameters
instanceIdstringThe FoundationaLLM instance identifier.
sessionIdstringThe identifier of the code session from where the files must be downloaded.
operationIdstringThe code session file upload operation identifier.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity providing the user identity information.
Returns
- Task<Result<CodeSessionFileDownloadResponse>>
A Task producing a Result<T> whose value is a CodeSessionFileDownloadResponse containing downloaded file records and any errors; otherwise a failed result with a domain error.
Remarks
By newly created files we mean files that were not uploaded to the code session but were created during the code execution.
The operationId is the identifier of the file upload operation that initially uploaded the files.
ExecuteCodeInCodeSession(string, string, string, UnifiedUserIdentity)
Executes code in a code session and returns the result of the execution.
public Task<Result<CodeSessionCodeExecuteResponse>> ExecuteCodeInCodeSession(string instanceId, string sessionId, string codeToExecute, UnifiedUserIdentity userIdentity)
Parameters
instanceIdstringThe FoundationaLLM instance identifier.
sessionIdstringThe identifier of the code session where the code must be executed.
codeToExecutestringThe code to execute.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity providing the user identity information.
Returns
- Task<Result<CodeSessionCodeExecuteResponse>>
A Task producing a Result<T> whose value is a CodeSessionCodeExecuteResponse with execution status, result, standard output, and error output; otherwise a failed result with a domain error.
UploadFilesToCodeSession(string, string, CodeSessionFileUploadRequest, UnifiedUserIdentity)
Uploads files to a code session.
public Task<Result<CodeSessionFileUploadResponse>> UploadFilesToCodeSession(string instanceId, string sessionId, CodeSessionFileUploadRequest request, UnifiedUserIdentity userIdentity)
Parameters
instanceIdstringThe FoundationaLLM instance identifier.
sessionIdstringThe identifier of the code session where the files must be uploaded.
requestCodeSessionFileUploadRequestThe CodeSessionFileUploadRequest providing the details of the request.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity providing the user identity information.
Returns
- Task<Result<CodeSessionFileUploadResponse>>
A Task producing a Result<T> whose value is a CodeSessionFileUploadResponse containing per-file upload success data; otherwise a failed result with a domain error.