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.
This PR adds web search functionality to the Discord bot, allowing users to get real-time information from the internet through OpenAI's web search preview API.
New Features :
Commands
/websearch [message]
- Direct web search command that always uses web search capabilities/togglewebsearch
- Toggle web search mode for all chat interactions (affects both/chat
andreplyall
mode)Enhanced
/chat
- Now respects the web search toggle settingFunctionality :
Smart fallback: If web search fails, automatically falls back to regular chat completion
OpenAI integration: Uses OpenAI's responses.create() API with web search preview tools
Web Search Flow
Check if OpenAI is enabled and web search conditions are met
Attempt web search using OpenAI's responses API with web_search_preview tool
On success: Return web search results with citations
On failure: Automatically fallback to regular chat completion
Dependencies
Why httpx==0.27.2 is Required ?
OpenAI Client Dependency: The OpenAI Python library uses httpx as its underlying HTTP client for making async requests
Web Search API: OpenAI's responses API (used for web search) requires reliable async HTTP handling
Version Compatibility: Version 0.27.2 ensures compatibility with openai==1.93.0 and provides: