OpenAI Plugin Now Supports Web Search Functionality #1569
Merged
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.
OpenAI Plugin Now Supports Web Search Functionality
Summary
This pull request adds web search functionality to the OpenAI plugin, expanding the existing search capability beyond Anthropic models to include OpenAI models. The implementation includes proper citation handling and formatting for search results.
Screenshots
These are both using
gpt-4o
as the default modelBefore Change
After Change
Files Changed
cli/flags.go
Search
flag to reflect that it now supports both Anthropic and OpenAI modelsplugins/ai/openai/openai.go
fmt
package to support citation formattingbuildResponseParams
method to include web search tool when enabledextractText
method to parse and format citations from search resultsplugins/ai/openai/openai_test.go
strings
andresponses
packagesCode Changes
Web Search Tool Integration
The
buildResponseParams
method now includes web search tool configuration:Citation Extraction and Formatting
The
extractText
method has been significantly enhanced to handle citations:Reason for Changes
This enhancement brings feature parity between the Anthropic and OpenAI plugins by adding web search capabilities to OpenAI models. The implementation allows users to leverage real-time web search results when using OpenAI models, with proper citation formatting for transparency and reference.
Impact of Changes
Positive Impacts
Potential Risks
Test Plan
The changes include comprehensive test coverage:
Run the test suite with:
go test ./plugins/ai/openai/...
Additional Notes
Breaking Changes: None - all changes are additive and backward compatible.
Dependencies: Requires OpenAI Go SDK with web search preview support.