GitHub user Alanxtl edited a discussion: [AI] llm供应商适配器构思
Pixiu AI 网关将输入统一为openai格式,通过一个适配器filter转换成对应的供应商的格式
```mermaid
graph TD
subgraph "客户端 (Client)"
UserRequest("👤 用户/客户端")
end
subgraph "AI 网关 (AI Gateway)"
A["入口: 接收标准OpenAI格式请求"]
B{"选择对应的适配器"}
subgraph "适配层 (Adapter Layer)"
C1["适配器: OpenAI (透传)"]
C2["适配器: Anthropic Claude"]
C3["适配器: Google Gemini"]
C4["适配器: ...更多"]
end
A --> B
B -- "model: 'gpt-4o'" --> C1
B -- "model: 'claude-3-opus-20240229'" --> C2
B -- "model: 'gemini-1.5-pro'" --> C3
end
subgraph "LLM 供应商 (LLM Providers)"
D1[☁️ OpenAI API]
D2[☁️ Anthropic API]
D3[☁️ Google AI API]
end
C1 --> D1
C2 --> D2
C3 --> D3
%% --- 转换过程示例 (Conversion Example) ---
subgraph "转换示例: OpenAI -> Anthropic"
direction LR
Input("输入请求 (OpenAI 格式):
POST /v1/chat/completions
{
'model': 'claude-3-opus-20240229',
'messages': [
{ 'role': 'system', 'content': '你是一个乐于助人的助手。' },
{ 'role': 'user', 'content': '你好,克劳德!' } ],
'max_tokens': 1024 }"
)
Output("输出请求 (Anthropic 格式):
POST /v1/messages
{
'model': 'claude-3-opus-20240229',
'system': '你是一个乐于助人的助手。',
'messages': [
{ 'role': 'user', 'content': '你好,克劳德!' } ],
'max_tokens': 1024 }"
)
Input -- "通过 Claude 适配器处理" --> Output
end
UserRequest --> A
%% Styling
style A fill:#D6EAF8,stroke:#3498DB
style B fill:#E8DAEF,stroke:#8E44AD
style C2 fill:#D5F5E3,stroke:#2ECC71
style Input fill:#FEF9E7,stroke:#F1C40F
style Output fill:#FDEDEC,stroke:#E74C3C
style C2 fill:#D5F5E3,stroke:#2ECC71
style A fill:#D6EAF8,stroke:#3498DB
style B fill:#E8DAEF,stroke:#8E44AD
style Output fill:#FDEDEC,stroke:#E74C3C
```
GitHub link: https://github.com/apache/dubbo-go-pixiu/discussions/686
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]