Repository navigation
Add WorkflowCore.AI: ChatClientStep for Microsoft.Extensions.AI IChatClient - #1453
Open
danielgerlag wants to merge 1 commit into
Open
danielgerlag wants to merge 1 commit into
danielgerlag wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Adds a new package,
WorkflowCore.AI, with one step body,ChatClientStep. It calls a model throughIChatClientfrom Microsoft.Extensions.AI, resolved from DI, so any provider with anIChatClient(OpenAI, Azure OpenAI, Ollama and others) can be used from a workflow. Temporal and Microsoft Agent Framework already offer this pattern for .NET; Workflow Core only had the Azure Foundry specific steps.Design choices
Prompt,Messages(IList<ChatMessage>),SystemPrompt,Options(ChatOptions). The request is sent as system prompt, then messages, then prompt as a user message. At least one ofPromptorMessagesis required, otherwise the step throws before calling the model.ResponseTextand the fullChatResponseasResponse.src/extensions/WorkflowCore.AI,netstandard2.0like the other extensions, soWorkflowCoregets no new dependency. It depends only onMicrosoft.Extensions.AI.Abstractions10.10.1..Input/.Outputmapping already covers it, soAddWorkflowChatClientStep()(registers the step in DI) is the only helper.How it was tested
New
test/WorkflowCore.AI.Tests(net6.0, net8.0, net10.0) with a fakeIChatClient, no network or keys:ChatOptionspass through, messages only, missing input throws without calling the model, null client rejectedWorkflowCore.Testing: a real workflow host resolves the step and the client from DI and maps the reply into workflow dataResults:
dotnet build WorkflowCore.sln: succeeded, 0 errorsWorkflowCore.AI.Tests: 6/6 on each of net6.0, net8.0, net10.0WorkflowCore.AI.AzureFoundry.Tests: 14/14WorkflowCore.UnitTests: 62 per framework;should_run_pre_middlewares(SyncWorkflowRunnerTests) failed on net8.0 and net10.0 in this run. This PR does not touch core, and the same test also fails intermittently onmaster, so it is pre-existing and unrelated.Limits
IChatClientper container is used; keyed clients are not supported yet.Responseis mapped to workflow data it is persisted with the instance, which can be large.