| | | 1 | | using Elsa.AI.Abstractions.Contracts; |
| | | 2 | | using Elsa.AI.Abstractions.Models; |
| | | 3 | | using Elsa.AI.Copilot.Options; |
| | | 4 | | using Microsoft.Extensions.Options; |
| | | 5 | | |
| | | 6 | | namespace Elsa.AI.Copilot.Adapters; |
| | | 7 | | |
| | 0 | 8 | | public class CopilotProvider(IOptions<CopilotOptions> options) : IAIProvider |
| | | 9 | | { |
| | 0 | 10 | | public string Name => options.Value.ProviderName ?? "copilot"; |
| | | 11 | | |
| | | 12 | | public ValueTask<AISessionHandle> CreateSessionAsync(CreateAISessionRequest request, CancellationToken cancellationT |
| | | 13 | | { |
| | 0 | 14 | | var providerName = request.ProviderConfiguration?.Name ?? options.Value.ProviderName ?? "copilot"; |
| | | 15 | | |
| | 0 | 16 | | return ValueTask.FromResult(new AISessionHandle |
| | 0 | 17 | | { |
| | 0 | 18 | | Id = request.ConversationId, |
| | 0 | 19 | | ProviderSessionId = $"{providerName}:{request.ConversationId}" |
| | 0 | 20 | | }); |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | public async IAsyncEnumerable<AIProviderEvent> ExecuteTurnAsync(AITurnRequest request, [System.Runtime.CompilerServi |
| | | 24 | | { |
| | 0 | 25 | | await Task.Yield(); |
| | | 26 | | |
| | 0 | 27 | | yield return new AIProviderEvent |
| | 0 | 28 | | { |
| | 0 | 29 | | Type = "assistant.delta", |
| | 0 | 30 | | Sequence = 1, |
| | 0 | 31 | | Timestamp = DateTimeOffset.UtcNow, |
| | 0 | 32 | | Data = new JsonObject |
| | 0 | 33 | | { |
| | 0 | 34 | | ["content"] = "Copilot adapter is registered. Runtime CLI integration is deferred to the provider implem |
| | 0 | 35 | | } |
| | 0 | 36 | | }; |
| | 0 | 37 | | } |
| | | 38 | | } |