Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true

# Limit consecutive empty lines (not always respected everywhere)
csharp_style_allow_multiple_blank_lines_experimental = false

dotnet_diagnostic.IDE0290.severity = none
dotnet_diagnostic.IDE0305.severity = none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ public interface IAIClientProvider
/// <param name = "deploymentName">The optional deployment name to use.</param>
/// <returns>An array of available <see cref = "SpeechVoice"/> instances.</returns>
Task<SpeechVoice[]> GetSpeechVoicesAsync(AIProviderConnectionEntry connection, string deploymentName = null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public static IEnumerable<AIDeploymentType> GetSupportedTypes(this AIDeploymentT
{
return Enum.GetValues<AIDeploymentType>().Where(type => value.Supports(type));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ public int NextReferenceIndex()
{
return Interlocked.Increment(ref _referenceIndex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ public void Dispose()
_current.Value = null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using CrestApps.Core.AI.Models;
using CrestApps.Core.Services;

namespace CrestApps.Core.AI.Profiles;
/// <summary>
/// Manages AI profiles with CRUD operations, name-based lookup,
/// and type-filtered retrieval. AI profiles define chat, agent, and embedding
/// configurations that drive AI completion behavior.
/// </summary>
public interface IAIProfileManager : INamedCatalogManager<AIProfile>
{
/// <summary>
/// Asynchronously retrieves a collection of AI chat profiles of the specified type.
/// </summary>
/// <param name="type">The type of AI chat profiles to retrieve.</param>
/// <returns>A ValueTask that represents the asynchronous operation. The result is an enumerable collection of AIProfile objects matching the specified type.</returns>
ValueTask<IEnumerable<AIProfile>> GetAsync(AIProfileType type);
}
using CrestApps.Core.AI.Models;
using CrestApps.Core.Services;

namespace CrestApps.Core.AI.Profiles;

/// <summary>
/// Manages AI profiles with CRUD operations, name-based lookup,
/// and type-filtered retrieval. AI profiles define chat, agent, and embedding
/// configurations that drive AI completion behavior.
/// </summary>
public interface IAIProfileManager : INamedCatalogManager<AIProfile>
{
/// <summary>
/// Asynchronously retrieves a collection of AI chat profiles of the specified type.
/// </summary>
/// <param name="type">The type of AI chat profiles to retrieve.</param>
/// <returns>A ValueTask that represents the asynchronous operation. The result is an enumerable collection of AIProfile objects matching the specified type.</returns>
ValueTask<IEnumerable<AIProfile>> GetAsync(AIProfileType type);
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
using CrestApps.Core.AI.Models;
using CrestApps.Core.Services;
namespace CrestApps.Core.AI.Profiles;
/// <summary>
/// Provides persistent storage for AI profiles, supporting CRUD operations,
/// name-based lookup, and efficient type-filtered queries via index.
/// </summary>
public interface IAIProfileStore : INamedCatalog<AIProfile>
{
/// <summary>
/// Asynchronously retrieves a collection of AI profiles of the specified type
/// using an efficient index query rather than loading all profiles.
/// </summary>
/// <param name="type">The type of AI profiles to retrieve.</param>
/// <returns>
/// A <see cref="ValueTask{TResult}"/> representing the asynchronous operation.
/// The result is a read-only collection of <see cref="AIProfile"/> matching the specified type.
/// </returns>
ValueTask<IReadOnlyCollection<AIProfile>> GetByTypeAsync(AIProfileType type);
}
using CrestApps.Core.AI.Models;
using CrestApps.Core.Services;

namespace CrestApps.Core.AI.Profiles;

/// <summary>
/// Provides persistent storage for AI profiles, supporting CRUD operations,
/// name-based lookup, and efficient type-filtered queries via index.
/// </summary>
public interface IAIProfileStore : INamedCatalog<AIProfile>
{
/// <summary>
/// Asynchronously retrieves a collection of AI profiles of the specified type
/// using an efficient index query rather than loading all profiles.
/// </summary>
/// <param name="type">The type of AI profiles to retrieve.</param>
/// <returns>
/// A <see cref="ValueTask{TResult}"/> representing the asynchronous operation.
/// The result is a read-only collection of <see cref="AIProfile"/> matching the specified type.
/// </returns>
ValueTask<IReadOnlyCollection<AIProfile>> GetByTypeAsync(AIProfileType type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ public static ChatResponseHandlerResult Streaming(IAsyncEnumerable<ChatResponseU
ResponseStream = stream
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public void Fail(ValidationResult error)
_errors ??= [];
_errors.Add(error);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ object ICloneable.Clone()
{
return Clone();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ private static double ScoreRelevance(HashSet<string> queryTokens, HashSet<string
var reverseScore = (double)matchCount / targetTokens.Count;
return Math.Max(forwardScore, reverseScore);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ protected override async ValueTask<object> InvokeCoreAsync(AIFunctionArguments a
return "An error occurred while searching for tools.";
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ protected override async ValueTask<object> InvokeCoreAsync(AIFunctionArguments a

return agents.Count > 0 ? JsonSerializer.Serialize(agents) : "No agents are currently available.";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public Task BuiltAsync(AICompletionContextBuiltContext context)
{
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ private static string GetCacheKey(string connectionId)
{
return $"A2AAgentCard:{connectionId}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,4 @@ private sealed class OAuth2TokenResponse
[JsonPropertyName("expires_in")]
public int ExpiresIn { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ protected override ISpeechToTextClient GetSpeechToTextClient(AIProviderConnectio
{
throw new NotSupportedException("Azure AI Inference does not currently support speech-to-text functionality.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ protected override string ProviderName
return AzureAIInferenceConstants.ProviderName;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ private async Task<string> ResolveSystemMessageAsync(ChatInteraction interaction

return parts.Count == 0 ? null : string.Join(Environment.NewLine + Environment.NewLine, parts);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ private static string GetString(JsonElement element, string propertyName)

return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public async Task BuiltAsync(OrchestrationContextBuiltContext context)
_logger.LogDebug("Injected extracted session state for AIProfile '{ProfileId}' with {CollectedCount} collected field(s) and {MissingCount} missing field(s).", profile.ItemId, collectedFields.Count, missingFields.Count);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ private static string GetString(JsonElement element, string propertyName)

return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using CrestApps.Core.AI.Claude.Models;
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Claude.Models;
using CrestApps.Core.AI.Models;

namespace CrestApps.Core.AI.Claude.Handlers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Claude.Handlers;
using CrestApps.Core.AI.Claude.Services;
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Orchestration;
using CrestApps.Core.Builders;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ private static bool GetBool(JsonElement element, string propertyName)

return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public Task BuiltAsync(OrchestrationContextBuiltContext context)
{
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -576,4 +576,4 @@ private static ChatResponseUpdate CreateTextResponse(string responseText)
Contents = [new TextContent(responseText)],
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public string NormalizeTitle(string title)
{
return RagTextNormalizer.NormalizeTitle(title);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ private static string NormalizeContentWhitespace(string text)
private static partial Regex MultipleNewlinesRegex();
[GeneratedRegex(@"\s+")]
private static partial Regex AllWhitespaceRegex();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public Task BuiltAsync(AICompletionContextBuiltContext context)
{
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public McpClientTransportEntry(string type)
public string Type { get; private set; }
public LocalizedString DisplayName { get; set; }
public LocalizedString Description { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Primitives/CrestApps.Core.AI.Mcp/Models/McpOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ public McpResourceTypeEntry(string type)
/// These are displayed in the UI to help users understand what variables can be used in URI patterns.
/// </summary>
public McpResourceVariable[] SupportedVariables { get; set; } = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ private sealed class OAuth2TokenResponse
[System.Text.Json.Serialization.JsonPropertyName("expires_in")]
public int ExpiresIn { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ private string Unprotect(IDataProtector protector, string value)
return value;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public Task<IClientTransport> GetAsync(McpConnection connection)

return Task.FromResult<IClientTransport>(transport);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ protected override ISpeechToTextClient GetSpeechToTextClient(AIProviderConnectio
{
throw new NotSupportedException("Ollama does not currently support speech-to-text functionality.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ protected override string ProviderName
return OllamaConstants.ProviderName;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ private AzureOpenAIClient GetClient(AIProviderConnectionEntry connection, Uri en
};
return azureClient;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,4 @@ private async Task RecordUsageAsync(AICompletionContext context, string connecti
var record = AICompletionUsageRecordFactory.Create(context, AzureOpenAIConstants.ClientName, Name, connectionName, deploymentName, modelName, responseId, usage?.InputTokenCount ?? 0, usage?.OutputTokenCount ?? 0, usage?.TotalTokenCount ?? 0, responseLatencyMs, isStreaming);
await observers.InvokeHandlersAsync((observer, usageRecord) => observer.UsageRecordedAsync(usageRecord, cancellationToken), record, _logger);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ private static (Uri endpoint, AzureAuthenticationType authType, string apiKey, s
var identityId = connection.GetIdentityId();
return (endpoint, authType, apiKey, identityId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,4 @@ private static bool IsGStreamerError(ApplicationException ex)
{
return ex.Message.Contains("0x29", StringComparison.OrdinalIgnoreCase) || ex.Message.Contains("GSTREAMER", StringComparison.OrdinalIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ private static OpenAIClient GetOpenAIClient(AIProviderConnectionEntry connection

return new OpenAIClient(new ApiKeyCredential(connection.GetApiKey()), new OpenAIClientOptions { Endpoint = endpoint, });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ protected override string ProviderName
return OpenAIConstants.ProviderName;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Primitives/CrestApps.Core.AI/AIOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ public void AddTemplateSource(string name, Action<AITemplateSourceEntry> configu

_templateSources[name] = entry;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ public static bool TryGetFirst<T>(this AIFunctionArguments arguments, string key
return false;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public virtual Task MessageCompletedAsync(ChatMessageCompletedContext context)
{
return Task.CompletedTask;
}
}
}
Loading
Loading