| | |
| | | public required string RequestId { get; init; } |
| | | public required string PluginId { get; init; } |
| | | public required string InstanceId { get; init; } |
| | | public string Mode { get; init; } = LlmConnectionModes.ProviderDirect; |
| | | public string? ProjectId { get; init; } |
| | | public required string ModelId { get; init; } |
| | | public required IReadOnlyList<LlmMessage> Messages { get; init; } |
| | | public LlmRequestOptions Options { get; init; } = new(); |
| | | public LlmPluginRuntimeConfig RuntimeConfig { get; init; } = new(); |
| | | } |
| | | |
| | | public sealed record LlmMessage |
| | |
| | | public const string Timeout = "LlmTimeout"; |
| | | public const string StreamParseFailed = "LlmStreamParseFailed"; |
| | | public const string RequestInvalid = "LlmRequestInvalid"; |
| | | public const string AiChatCredentialMissing = "AiChatCredentialMissing"; |
| | | public const string AiChatLoginFailed = "AiChatLoginFailed"; |
| | | public const string AiChatProjectLoadFailed = "AiChatProjectLoadFailed"; |
| | | public const string AiChatQuotaExceeded = "AiChatQuotaExceeded"; |
| | | public const string AiChatMemoryPermissionDenied = "AiChatMemoryPermissionDenied"; |
| | | public const string AiChatSseInterrupted = "AiChatSseInterrupted"; |
| | | public const string AiChatApiFailed = "AiChatApiFailed"; |
| | | } |
| | | |
| | | public static class LlmConnectionModes |
| | | { |
| | | public const string ProviderDirect = "provider-direct"; |
| | | public const string AiChatApi = "aichat-api"; |
| | | } |
| | | |
| | | public sealed record LlmPluginRuntimeConfig |
| | | { |
| | | public string Mode { get; init; } = LlmConnectionModes.ProviderDirect; |
| | | public AiChatRuntimeConfig AiChat { get; init; } = new(); |
| | | public string? DefaultModel { get; init; } |
| | | public List<LlmModelConfig> Models { get; init; } = []; |
| | | |
| | | public bool IsAiChatMode => string.Equals(Mode, LlmConnectionModes.AiChatApi, StringComparison.OrdinalIgnoreCase); |
| | | } |
| | | |
| | | public sealed record AiChatRuntimeConfig |
| | | { |
| | | public string BaseUrl { get; init; } = "http://192.168.1.111:13000"; |
| | | public AiChatAccountConfig Account { get; init; } = new(); |
| | | public string? DefaultProjectId { get; init; } |
| | | public AiChatMemoryConfig Memory { get; init; } = new(); |
| | | } |
| | | |
| | | public sealed record AiChatAccountConfig |
| | | { |
| | | public string? Email { get; init; } |
| | | public string? Password { get; init; } |
| | | public string? PasswordEnv { get; init; } = "MOLI_AICHAT_PASSWORD"; |
| | | } |
| | | |
| | | public sealed record AiChatMemoryConfig |
| | | { |
| | | public bool EnabledInProviderDirect { get; init; } = true; |
| | | public string DefaultScope { get; init; } = "PROJECT"; |
| | | public int RecallLimit { get; init; } = 8; |
| | | } |
| | | |
| | | public sealed record AiChatProjectSummary |
| | | { |
| | | public required string Id { get; init; } |
| | | public required string Name { get; init; } |
| | | public string ProjectType { get; init; } = "CHAT"; |
| | | public string MemoryMode { get; init; } = "ISOLATED"; |
| | | } |
| | | |
| | | public sealed record AiChatMemoryCapabilities |
| | | { |
| | | public bool CanUseMemory { get; init; } |
| | | public bool CanViewMemory { get; init; } |
| | | public bool CanManageMemory { get; init; } |
| | | } |
| | | |
| | | public sealed record AiChatGetMemoriesRequest |
| | | { |
| | | public string? Scope { get; init; } |
| | | public string? ProjectId { get; init; } |
| | | } |
| | | |
| | | public sealed record AiChatCreateMemoryRequest |
| | | { |
| | | public required string Scope { get; init; } |
| | | public string? ProjectId { get; init; } |
| | | public required string Content { get; init; } |
| | | } |
| | | |
| | | public sealed record AiChatRecallMemoriesRequest |
| | | { |
| | | public required string Query { get; init; } |
| | | public string? Scope { get; init; } |
| | | public string? ProjectId { get; init; } |
| | | public string? ConversationId { get; init; } |
| | | public int? Limit { get; init; } |
| | | } |
| | | |
| | | public sealed record AiChatJsonResult |
| | | { |
| | | public object? Data { get; init; } |
| | | } |
| | | |
| | | public sealed class AiChatClientException : Exception |
| | | { |
| | | public AiChatClientException(string code, string message, Exception? innerException = null) |
| | | : base(message, innerException) |
| | | { |
| | | Code = code; |
| | | } |
| | | |
| | | public string Code { get; } |
| | | } |