获取 Text Chat 客户端实例(根据 type 返回对应客户端) Args: provider_config: 服务商配置字典 - type: 'google_gemini' 或 'openai_compatible' - api_key: API密钥 - base_url: API基础URL(可选) - endpoint_type: 自定义端点路径(可选) Returns: GenAIClient 或 TextChatClient
(provider_config: dict)
| 252 | |
| 253 | |
| 254 | def get_text_chat_client(provider_config: dict): |
| 255 | """ |
| 256 | 获取 Text Chat 客户端实例(根据 type 返回对应客户端) |
| 257 | |
| 258 | Args: |
| 259 | provider_config: 服务商配置字典 |
| 260 | - type: 'google_gemini' 或 'openai_compatible' |
| 261 | - api_key: API密钥 |
| 262 | - base_url: API基础URL(可选) |
| 263 | - endpoint_type: 自定义端点路径(可选) |
| 264 | |
| 265 | Returns: |
| 266 | GenAIClient 或 TextChatClient |
| 267 | """ |
| 268 | provider_type = provider_config.get('type', 'openai_compatible') |
| 269 | api_key = provider_config.get('api_key') |
| 270 | base_url = provider_config.get('base_url') |
| 271 | endpoint_type = provider_config.get('endpoint_type') |
| 272 | |
| 273 | if provider_type == 'google_gemini': |
| 274 | from .genai_client import GenAIClient |
| 275 | return GenAIClient(api_key=api_key, base_url=base_url) |
| 276 | else: |
| 277 | return TextChatClient(api_key=api_key, base_url=base_url, endpoint_type=endpoint_type) |
no test coverage detected