Add support for OpenAI web search options and Grok compat#74
Merged
Conversation
Member
kzu
commented
Jul 7, 2025
- Add OpenAI/Grok subnamespace: helps organize functionality areas
- Adds OpenAI WebSearchTool-specific extensions under that namespace: region, city, timezone, context size.
- Cross-provider compatibility by interpreting WebSearchTool as GrokSearch(Auto) with a GrokWebSource(country).
* Add OpenAI/Grok subnamespace: helps organize functionality areas * Adds OpenAI WebSearchTool-specific extensions under that namespace: region, city, timezone, context size. * Cross-provider compatibility by interpreting WebSearchTool as GrokSearch(Auto) with a GrokWebSource(country).
Member
Author
🧪 Details on Ubuntu 24.04.2 LTSfrom dotnet-retest v0.7.1 on .NET 8.0.17 with 💜 by @devlooped |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for OpenAI-specific web search options (region, city, timezone, context size) via a new sub-namespace, and ensures Grok compatibility by mapping the same tool to Grok’s live search API.
- Introduces
WebSearchToolunderDevlooped.Extensions.AIwith an extensiblePropertiesbag. - Supplies OpenAI extensions (
Region,City,TimeZone,ContextSize) inDevlooped.Extensions.AI.OpenAI. - Maps
WebSearchTooltoGrokChatWebSearchOptionsinDevlooped.Extensions.AI.Grok. - Adjusts namespaces for OpenAI/Grok client types and updates README with usage examples.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/AI/WebSearchTool.cs | Implements WebSearchTool with base country filtering and property bag. |
| src/AI/OpenAI/WebSearchToolExtensions.cs | Adds extension block for WebSearchTool to configure region, city, timezone, and context size. |
| src/AI/OpenAI/OpenAIChatClient.cs | Moves OpenAIChatClient into the OpenAI sub-namespace. |
| src/AI/Grok/GrokSearchTool.cs | Relocates GrokSearchTool into the Grok sub-namespace. |
| src/AI/Grok/GrokClient.cs | Maps WebSearchTool under GrokChatClient to GrokWebSource; qualifies global::OpenAI. |
| src/AI/Grok/GrokChatOptions.cs | Moves GrokChatOptions into the Grok sub-namespace. |
| src/AI/Grok/GrokChatClient.cs | Adds handling for WebSearchTool in the pipeline; global-qualifies OpenAI types. |
| src/AI.Tests/ToolsTests.cs | Updates tests to qualify OpenAIClientOptions with global::OpenAI. |
| src/AI.Tests/RetrievalTests.cs | Qualifies OpenAIClientOptions and FileUploadPurpose with global::OpenAI. |
| src/AI.Tests/OpenAITests.cs | Adds a live-search test using WebSearchTool; imports updated OpenAI namespace. |
| src/AI.Tests/GrokTests.cs | Qualifies OpenAIClientOptions import and ensures Grok namespace usage. |
| readme.md | Documents WebSearchTool usage for both OpenAI and Grok clients with examples. |
Comments suppressed due to low confidence (4)
src/AI/WebSearchTool.cs:7
- [nitpick] The summary only mentions country filtering. Update it to reflect that this tool also supports region, city, timezone, and context size.
/// Basic web search tool that can limit the search to a specific country.
src/AI/OpenAI/WebSearchToolExtensions.cs:32
- No tests cover the
Regionproperty; consider adding unit tests to verify that settingRegioncorrectly updates bothPropertiesand the underlyingLocation.
public string? Region
src/AI/WebSearchTool.cs:12
- The private field
regionis declared but never used. Consider removing it to reduce dead code.
string? region;
src/AI.Tests/OpenAITests.cs:99
- The test references
WebSearchToolbut only importsDevlooped.Extensions.AI.OpenAI. You needusing Devlooped.Extensions.AI;(or fully qualify) so thatWebSearchToolresolves correctly.
Tools = [new WebSearchTool("AR")
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.