mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Fix Azure OpenAI web_search_preview tool incompatibility
Azure OpenAI doesn't support the web_search_preview tool, which was causing "Hosted tool 'web_search_preview' is not supported" errors with GPT-5 models. ## Changes: - Pass dialect information to aixToOpenAIResponses function - Skip web_search_preview tool addition when dialect is 'azure' - Add logging when web search is skipped for Azure - Document known Azure limitations in implementation guide ## Impact: - Fixes web browsing errors with Azure GPT-5 models - Maintains web search functionality for regular OpenAI models - Provides clear logging for debugging This is a critical fix for Azure OpenAI compatibility as web search is not currently supported on Azure's Responses API implementation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -113,14 +113,33 @@ Tested with Azure OpenAI endpoint `https://grid4openai.openai.azure.com`:
|
||||
3. Add console logging is included to debug which API paradigm is being used
|
||||
4. Environment variables provide full control over API versions and paradigms
|
||||
|
||||
## Known Limitations
|
||||
|
||||
### Azure OpenAI Specific Limitations
|
||||
|
||||
1. **Web Search Tool**: Azure OpenAI doesn't currently support the `web_search_preview` tool
|
||||
- The fix automatically disables web search for Azure deployments
|
||||
- Logs when web search is skipped: `[Azure] Skipping web_search_preview tool - not supported on Azure OpenAI`
|
||||
- This affects all Azure models using the Responses API (GPT-5, o-series)
|
||||
|
||||
2. **GPT-5 Model Constraints**:
|
||||
- No temperature control (only default value of 1.0 supported)
|
||||
- Must use `max_completion_tokens` instead of `max_tokens`
|
||||
- These constraints are already handled in the existing code
|
||||
|
||||
3. **Image Generation**: Multi-turn editing and streaming not yet supported on Azure
|
||||
|
||||
4. **File Upload**: Images can't be uploaded as files and referenced as input (coming soon)
|
||||
|
||||
## Benefits
|
||||
|
||||
1. **Fixes Issue #828**: Resolves "Resource Not Found" errors for GPT-5 and o3 Pro models
|
||||
2. **Future-Proof**: Supports Azure's next-generation v1 API
|
||||
3. **Backward Compatible**: Maintains support for existing deployments
|
||||
4. **Robust**: Prevents malformed URLs from client misconfigurations
|
||||
5. **Configurable**: Full control over API paradigms and versions
|
||||
6. **Debuggable**: Includes logging for troubleshooting
|
||||
2. **Handles Azure Limitations**: Automatically disables unsupported features like web search
|
||||
3. **Future-Proof**: Supports Azure's next-generation v1 API
|
||||
4. **Backward Compatible**: Maintains support for existing deployments
|
||||
5. **Robust**: Prevents malformed URLs from client misconfigurations
|
||||
6. **Configurable**: Full control over API paradigms and versions
|
||||
7. **Debuggable**: Includes logging for troubleshooting
|
||||
|
||||
## Technical Details
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { OpenAIWire_API_Responses, OpenAIWire_Responses_Items, OpenAIWire_Respon
|
||||
|
||||
import { approxDocPart_To_String } from './anthropic.messageCreate';
|
||||
import { aixDocPart_to_OpenAITextContent, aixMetaRef_to_OpenAIText, aixTexts_to_OpenAIInstructionText } from '~/modules/aix/server/dispatch/chatGenerate/adapters/openai.chatCompletions';
|
||||
import type { OpenAIDialects } from '~/modules/llms/server/openai/openai.router';
|
||||
|
||||
|
||||
// configuration
|
||||
@@ -21,7 +22,7 @@ type TRequestTool = OpenAIWire_Responses_Tools.Tool;
|
||||
* - much side functionality is not implemented yet
|
||||
* - testing with o3-pro only for now
|
||||
*/
|
||||
export function aixToOpenAIResponses(model: AixAPI_Model, chatGenerate: AixAPIChatGenerate_Request, jsonOutput: boolean, streaming: boolean): TRequest {
|
||||
export function aixToOpenAIResponses(openAIDialect: OpenAIDialects | null, model: AixAPI_Model, chatGenerate: AixAPIChatGenerate_Request, jsonOutput: boolean, streaming: boolean): TRequest {
|
||||
|
||||
// [OpenAI] Vendor-specific model checks
|
||||
const isOpenAIOFamily = ['gpt-6', 'gpt-5', 'o4', 'o3', 'o1'].some(_id => model.id === _id || model.id.startsWith(_id + '-'));
|
||||
@@ -95,8 +96,16 @@ export function aixToOpenAIResponses(model: AixAPI_Model, chatGenerate: AixAPICh
|
||||
|
||||
// Tool: Search: for search models, and deep research models
|
||||
// NOTE: OpenAI doesn't support web search with minimal reasoning effort
|
||||
// NOTE: Azure OpenAI doesn't support web search tool yet (as of Aug 2025)
|
||||
const skipWebSearchDueToMinimalReasoning = model.vndOaiReasoningEffort === 'minimal';
|
||||
if ((hotFixForceSearchTool || model.vndOaiWebSearchContext || model.userGeolocation) && !skipWebSearchDueToMinimalReasoning) {
|
||||
const skipWebSearchDueToAzure = openAIDialect === 'azure';
|
||||
|
||||
// Log when web search is being skipped for Azure
|
||||
if ((hotFixForceSearchTool || model.vndOaiWebSearchContext || model.userGeolocation) && skipWebSearchDueToAzure) {
|
||||
console.log('[Azure] Skipping web_search_preview tool - not supported on Azure OpenAI');
|
||||
}
|
||||
|
||||
if ((hotFixForceSearchTool || model.vndOaiWebSearchContext || model.userGeolocation) && !skipWebSearchDueToMinimalReasoning && !skipWebSearchDueToAzure) {
|
||||
if (!payload.tools?.length)
|
||||
payload.tools = [];
|
||||
const webSearchTool: TRequestTool = {
|
||||
|
||||
@@ -101,7 +101,7 @@ export function createChatGenerateDispatch(access: AixAPI_Access, model: AixAPI_
|
||||
return {
|
||||
request: {
|
||||
...openAIAccess(access, model.id, '/v1/responses'),
|
||||
body: aixToOpenAIResponses(model, chatGenerate, false, streaming),
|
||||
body: aixToOpenAIResponses(access.dialect, model, chatGenerate, false, streaming),
|
||||
},
|
||||
demuxerFormat: streaming ? 'fast-sse' : null,
|
||||
chatGenerateParse: streaming ? createOpenAIResponsesEventParser() : createOpenAIResponseParserNS(),
|
||||
|
||||
Reference in New Issue
Block a user