解决
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
解决
Assistant
Based on the provided context, here's how to address the issue of adding OpenAI
/v1protocol support for Tencent Hunyuan in theai-proxyplugin:Understanding the Requirement
The core issue is that Tencent Hunyuan (a large language model from Tencent) has recently added compatibility with the OpenAI API request format (specifically
/v1/chat/completionsand/v1/embeddings). Theai-proxyplugin in Higress needs to be updated to handle this new compatibility, so that it can forward requests using the OpenAI protocol to Hunyuan.How to Implement the Solution
Here's a breakdown of the necessary steps and how they align with the provided code:
-
Add Hunyuan Provider Type:
- The
ai-proxy/README.mdfile already includes "混元" (Hunyuan) as a supportedtypewithhunyuan. - The
ai-proxy/main.gofile indicates a switch onprovider.type. So, We need to add hunyuan in the provider switch.
- The
-
Ensure correct handling of
/v1/chat/completionsand/v1/embeddings:- The
ai-proxy/main.gofile already contains the logic in thegetOpenAiApiNamefunction to identify requests with the/v1/chat/completionsand/v1/embeddingssuffixes. - The plugin already uses the OpenAI protocol to parse the request body when the path ends with those suffixes.
- We need to make sure that the hunyuan provider can handle the request body parsed by openai protocol.
- The
-
Hunyuan specific configuration:
- The
ai-proxy/README.mdindicates that Hunyuan requireshunyuanAuthIdandhunyuanAuthKeyfor authentication. These fields should be included in theprovider's configuration. - The
ai-proxy/README.mdalso states that it will use the provided apiToken for v3 authentication. It will usehunyuanAuthIdandhunyuanAuthKeyto obtain the apiToken.
- The
-
Code Changes:
-
./repos/higress/plugins/wasm-go/extensions/ai-proxy/README.md:- No modification is needed.
-
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.