fix(providers): add Azure AI Foundry host recognition for prompt caching and native search
This commit is contained in:
parent
100720bb74
commit
eb50a7fab7
2 changed files with 9 additions and 2 deletions
|
|
@ -417,7 +417,9 @@ func isNativeSearchHost(apiBase string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
host := u.Hostname()
|
host := u.Hostname()
|
||||||
return host == "api.openai.com" || strings.HasSuffix(host, ".openai.azure.com")
|
return host == "api.openai.com" ||
|
||||||
|
strings.HasSuffix(host, ".openai.azure.com") ||
|
||||||
|
strings.HasSuffix(host, ".services.ai.azure.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
// supportsPromptCacheKey reports whether the given API base is known to
|
// supportsPromptCacheKey reports whether the given API base is known to
|
||||||
|
|
@ -430,5 +432,7 @@ func supportsPromptCacheKey(apiBase string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
host := u.Hostname()
|
host := u.Hostname()
|
||||||
return host == "api.openai.com" || strings.HasSuffix(host, ".openai.azure.com")
|
return host == "api.openai.com" ||
|
||||||
|
strings.HasSuffix(host, ".openai.azure.com") ||
|
||||||
|
strings.HasSuffix(host, ".services.ai.azure.com")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -831,6 +831,8 @@ func TestSupportsPromptCacheKey(t *testing.T) {
|
||||||
{"https://api.groq.com/openai/v1", false},
|
{"https://api.groq.com/openai/v1", false},
|
||||||
{"http://localhost:11434/v1", false},
|
{"http://localhost:11434/v1", false},
|
||||||
{"https://openrouter.ai/api/v1", false},
|
{"https://openrouter.ai/api/v1", false},
|
||||||
|
{"https://myfoundry.eastus.services.ai.azure.com/v1", true},
|
||||||
|
{"https://myfoundry.services.ai.azure.com", true},
|
||||||
// Edge cases: proxy URLs with openai.com in path should NOT match
|
// Edge cases: proxy URLs with openai.com in path should NOT match
|
||||||
{"https://my-proxy.com/api.openai.com/v1", false},
|
{"https://my-proxy.com/api.openai.com/v1", false},
|
||||||
{"https://proxy.example.com/openai.azure.com/v1", false},
|
{"https://proxy.example.com/openai.azure.com/v1", false},
|
||||||
|
|
@ -900,6 +902,7 @@ func TestIsNativeSearchHost(t *testing.T) {
|
||||||
{"https://api.deepseek.com/v1", false},
|
{"https://api.deepseek.com/v1", false},
|
||||||
{"https://api.groq.com/openai/v1", false},
|
{"https://api.groq.com/openai/v1", false},
|
||||||
{"http://localhost:11434/v1", false},
|
{"http://localhost:11434/v1", false},
|
||||||
|
{"https://myfoundry.eastus.services.ai.azure.com/v1", true},
|
||||||
{"", false},
|
{"", false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue