-
Notifications
You must be signed in to change notification settings - Fork 839
Add AITool.GetService #6830
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
Add AITool.GetService #6830
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a GetService
method to the AITool
base class to enable retrieval of services from tools, including the ability to reach through delegating tool layers to access inner services. This follows a consistent pattern used elsewhere in the Microsoft.Extensions.AI library.
- Added
GetService
method with both generic and non-generic overloads toAITool
base class - Updated delegating classes to forward
GetService
calls to their inner implementations - Modified existing code to use the new service retrieval pattern instead of direct type checking
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs | Adds the core GetService functionality to the AITool base class |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs | Implements GetService delegation to inner function |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunctionDeclaration.cs | Implements GetService delegation to inner function declaration |
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs | Updates approval-required function detection to use GetService pattern |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs | Implements GetService in ResponseToolAITool to expose wrapped ResponseTool |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/AIToolTests.cs | Adds comprehensive tests for the new GetService functionality |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Functions/DelegatingAIFunctionTests.cs | Tests GetService delegation in DelegatingAIFunction |
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs | Tests GetService functionality with ResponseTool wrapping |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.json | Updates API surface documentation for new methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Show resolved
Hide resolved
Following the same pattern as elsewhere in M.E.AI, this enables a consumer to reach through layers of delegating tools to grab information from inner ones, such as whether they were marked as requiring approval.
54c6a59
to
09670a7
Compare
.../Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Functions/DelegatingAIFunctionTests.cs
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/AIToolTests.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs
Show resolved
Hide resolved
Following the same pattern as elsewhere in M.E.AI, this enables a consumer to reach through layers of delegating tools to grab information from inner ones, such as whether they were marked as requiring approval.
Following the same pattern as elsewhere in M.E.AI, this enables a consumer to reach through layers of delegating tools to grab information from inner ones, such as whether they were marked as requiring approval.
cc: @westey-m, @rogerbarreto
Microsoft Reviewers: Open in CodeFlow