mirror of
https://github.com/alibaba/higress.git
synced 2026-06-05 10:37:28 +08:00
fix(ai-proxy): Fix Azure OpenAI Response API handling and service URL type detection (#2948)
This commit is contained in:
@@ -38,6 +38,7 @@ var (
|
||||
ApiNameFiles: true,
|
||||
ApiNameRetrieveFile: true,
|
||||
ApiNameRetrieveFileContent: true,
|
||||
ApiNameResponses: true,
|
||||
}
|
||||
regexAzureModelWithPath = regexp.MustCompile("/openai/deployments/(.+?)(?:/(.*)|$)")
|
||||
)
|
||||
@@ -100,8 +101,15 @@ func (m *azureProviderInitializer) CreateProvider(config ProviderConfig) (Provid
|
||||
}
|
||||
log.Debugf("azureProvider: found default model from serviceUrl: %s", defaultModel)
|
||||
} else {
|
||||
serviceUrlType = azureServiceUrlTypeDomainOnly
|
||||
log.Debugf("azureProvider: no default model found in serviceUrl")
|
||||
// If path doesn't match the /openai/deployments pattern,
|
||||
// check if it's a custom full path or domain only
|
||||
if serviceUrl.Path != "" && serviceUrl.Path != "/" {
|
||||
serviceUrlType = azureServiceUrlTypeFull
|
||||
log.Debugf("azureProvider: using custom full path: %s", serviceUrl.Path)
|
||||
} else {
|
||||
serviceUrlType = azureServiceUrlTypeDomainOnly
|
||||
log.Debugf("azureProvider: no default model found in serviceUrl")
|
||||
}
|
||||
}
|
||||
log.Debugf("azureProvider: serviceUrlType=%d", serviceUrlType)
|
||||
|
||||
|
||||
@@ -825,7 +825,7 @@ func ExtractStreamingEvents(ctx wrapper.HttpContext, chunk []byte) []StreamEvent
|
||||
continue
|
||||
}
|
||||
|
||||
if lineStartIndex != -1 {
|
||||
if lineStartIndex != -1 && valueStartIndex != -1 {
|
||||
value := string(body[valueStartIndex:i])
|
||||
currentEvent.SetValue(currentKey, value)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user