Skip to content

Conversation

@johnlanni
Copy link
Collaborator

What Changed

  • Fixed Azure service URL type detection logic: Added proper handling for custom full paths that don't match the /openai/deployments pattern
  • Added support for Azure OpenAI Response API: Enhanced Azure provider to properly handle the response API endpoints
  • Improved streaming event parsing: Fixed edge case in ExtractStreamingEvents where valueStartIndex could be -1

Key Improvements

1. Enhanced service URL type detection

  • Now correctly identifies custom full paths as azureServiceUrlTypeFull instead of incorrectly categorizing them as azureServiceUrlTypeDomainOnly
  • Maintains backward compatibility with existing deployment-based URLs

2. Azure Response API support

  • Added ApiNameResponses to model-irrelevant APIs list
  • Updated capability mapping to handle response API paths correctly
  • Added comprehensive test coverage for the new functionality

3. Bug fix for streaming

  • Added null check for valueStartIndex in streaming event extraction to prevent potential issues

Testing

  • Added new test cases for Azure Response API configuration and request handling
  • Verified proper path transformation for response API endpoints
  • Maintained existing test coverage for standard Azure OpenAI functionality

Summary

This fix ensures that Azure OpenAI integrations work correctly with both standard chat completion APIs and the new response API, while properly handling various service URL configurations.

Files Changed

  • provider/azure.go - Main logic fixes and enhancements
  • provider/provider.go - Streaming event parsing fix
  • test/azure.go - Added comprehensive test coverage

@lingma-agents
Copy link

lingma-agents bot commented Sep 23, 2025

修复 Azure OpenAI 响应 API 处理及服务 URL 类型检测

变更概述
  • 问题修复
    • 修复了 Azure 服务 URL 类型检测逻辑,确保自定义完整路径能被正确识别为 azureServiceUrlTypeFull,而不是错误地归类为 azureServiceUrlTypeDomainOnly
    • 修复了 ExtractStreamingEvents 中的边缘情况,当 valueStartIndex 为 -1 时增加空值检查以防止潜在问题
  • 新功能
    • 增加对 Azure OpenAI 响应 API 的支持,更新能力映射以正确处理响应 API 路径
    • 在模型无关 API 列表中新增 ApiNameResponses
  • 测试更新
    • 增加了针对 Azure 响应 API 配置和请求处理的测试用例
    • 验证了响应 API 端点的路径转换功能
    • 维持了现有 Azure OpenAI 功能的测试覆盖率
变更文件
文件路径 变更说明
plugins/​wasm-go/​extensions/​ai-proxy/​provider/​azure.​go 添加了对 Azure OpenAI 响应 API 的支持,改进了服务 URL 类型检测逻辑,确保自定义路径被正确处理。
plugins/​wasm-go/​extensions/​ai-proxy/​provider/​provider.​go 修复了流式事件解析中的边缘情况,增加了对 `valueStartIndex` 的空值检查。
plugins/​wasm-go/​extensions/​ai-proxy/​test/​azure.​go 新增了 Azure OpenAI 响应 API 的测试配置和测试用例,验证了请求体处理和路径转换功能。
时序图
sequenceDiagram
    participant PC as ProviderConfig
    participant AP as AzureProvider
    participant SE as StreamingEvents
    PC->>AP: CreateProvider(config)
    Note over AP: 检测服务 URL 类型<br/>处理响应 API 路径
    AP-->>PC: 返回 AzureProvider 实例
    SE->>SE: ExtractStreamingEvents(chunk)
    Note over SE: 增加 valueStartIndex 空值检查
Loading

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

--- ### Fix Azure OpenAI Response API Processing and Service URL Type Detection
Change Overview

Problem fix

  • Fixed Azure Service URL type detection logic to ensure that custom full paths are correctly recognized as azureServiceUrlTypeFull instead of incorrectly categorized as azureServiceUrlTypeDomainOnly
  • Fixed edge case in ExtractStreamingEvents, adding null value checks when valueStartIndex is -1 to prevent potential issues
  • New Features
    • Add support for Azure OpenAI response API, update capability maps to correctly handle response API paths
    • Added ApiNameResponses to the Model Non-Related API list
      Test Update
    • Added test cases for Azure Response API configuration and request processing
    • Verified path conversion functionality of response API endpoints
    • Maintain test coverage of existing Azure OpenAI capabilities
Change file
File path Change instructions
plugins/​wasm-go/​extensions/​ai-proxy/​provider/​azure.​go Added support for the Azure OpenAI response API, improved service URL type detection logic, and ensures that custom paths are processed correctly.
plugins/​wasm-go/​extensions/​ai-proxy/​provider/​provider.​go Fixed edge cases in streaming event resolution and added null checks for `valueStartIndex`.
plugins/​wasm-go/​extensions/​ai-proxy/​test/​azure.​go A new test configuration and test cases for Azure OpenAI response API are added, verifying request body processing and path conversion capabilities.
Sequence chart
sequenceDiagram
    participant PC as ProviderConfig
    participant AP as AzureProvider
    participant SE as StreamingEvents
    PC->>AP: CreateProvider(config)
    Note over AP: Detect service URL type<br/> Process response API path
    AP-->>PC: Return to AzureProvider instance
    SE->>SE: ExtractStreamingEvents(chunk)
    Note over SE: Increase valueStartIndex null value check
Loading

💡 Tips

How to communicate with lingma-agents

📜 Reply to comments directly
Reply to this comment directly and lingma-agents will automatically process your request. For example:

  • _Add detailed comment description in the current code. _

  • _Please introduce the LRU transformation plan you mentioned in detail and explain it using pseudo-code. _

**📜 Mark ** at line of code
Create comments at a specific location in the file and @lingma-agents. For example:

  • _@lingma-agents Analyze the performance bottlenecks of this method and provide optimization suggestions. _

  • _@lingma-agents Generate optimization code for this method. _

📜 Ask a question during discussion
In any discussion @lingma-agents to get help. For example:

  • _@lingma-agents Please summarize the above discussion and propose solutions. _

  • _@lingma-agents Please generate optimization code based on the discussion content. _

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.95%. Comparing base (ef31e09) to head (d32bad4).
⚠️ Report is 725 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2948      +/-   ##
==========================================
+ Coverage   35.91%   44.95%   +9.03%     
==========================================
  Files          69       82      +13     
  Lines       11576    13377    +1801     
==========================================
+ Hits         4157     6013    +1856     
+ Misses       7104     7016      -88     
- Partials      315      348      +33     

see 80 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@johnlanni johnlanni merged commit 623c8da into alibaba:main Sep 23, 2025
15 checks passed
Tsukilc pushed a commit to Tsukilc/higress that referenced this pull request Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants