Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change AIFunction.InvokeAsync to accept AIFunctionArguments #6158

Merged
merged 2 commits into from
Mar 19, 2025

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Mar 19, 2025

  • Adds a new AIFunctionArguments type.
  • Changes AIFunction.InvokeAsync to accept an AIFunctionArguments instead of an arbitrary enumerable.
  • Changes FunctionInvokingChatClient to accept an IServiceProvider and expose it as a Services property, and to then pass that IServiceProvider into the AIFunction via AIFunctionArguments.Services.
  • Augments FunctionInvocationContext with an AIFunctionArguments property.
  • Changes AIFunctionFactory to special-case parameters of type IServiceProvider and AIFunctionArguments, sourcing from AIFunctionArguments.
  • Makes AIJsonSchemaCreateOptions a record.
Microsoft Reviewers: Open in CodeFlow

@stephentoub
Copy link
Member Author

@SteveSandersonMS, @halter73, as this is a fundamental change, I'd like a second review before merging. Thanks!

Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted some minor questions but the overall thing look great.

Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I agree that adding an optional IServiceProvider argument to OpenAIRealtimeExtensions.HandleToolCallsAsync would be a good idea, but that could be done as a follow up.

- Adds a new AIFunctionArguments type.
- Changes AIFunction.InvokeAsync to accept an AIFunctionArguments instead of an arbitrary enumerable.
- Changes FunctionInvokingChatClient to accept an IServiceProvider and expose it as a Services property, and to then pass that IServiceProvider into the AIFunction via AIFunctionArguments.Services.
- Augments FunctionInvocationContext with an AIFunctionArguments property.
- Changes AIFunctionFactory to special-case parameters of type IServiceProvider and AIFunctionArguments, sourcing from AIFunctionArguments.
- Makes AIJsonSchemaCreateOptions a record.
@stephentoub stephentoub force-pushed the aifunctionarguments branch from f5e7c7b to fe4453c Compare March 19, 2025 22:39
@stephentoub stephentoub enabled auto-merge (squash) March 19, 2025 22:40
@stephentoub stephentoub merged commit 6694f06 into dotnet:main Mar 19, 2025
6 checks passed
@stephentoub stephentoub deleted the aifunctionarguments branch March 19, 2025 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants