ai365vip / chat-api

基于One API与New API的基础上进行二次开发
https://api.ai365vip.com/
Other
382 stars 92 forks source link

无法在 One API 中配置 Embedding API #47

Closed samni728 closed 3 months ago

samni728 commented 3 months ago

例行检查

问题描述 在尝试使用 One API 配置嵌入请求的自定义渠道时遇到问题。尽管设置了正确的 Base URL 和参数,但 API 将请求视为聊天模型调用,而不是嵌入调用,导致返回 400 状态码错误。

配置详情

•   Base URL: http://192.168.10.170:1234/v1/embeddings
•   API 密钥: lm-studio
•   模型: bge-large-zh
•   自定义请求体:

{ "model": "{{model}}", "input": ["{{input}}"], "max_tokens": "{{max_tokens}}" }

复现步骤

  1. 按如下截图配置自定义渠道:

image

2.{ "model": "bge-large-zh", "messages": [ { "role": "user", "content": "hi" } ], "max_tokens": 1 }

  1. 观察返回的错误: [2024-06-11 09:55:05.972] [ERROR] 'input' field is required 预期行为

请求应该被识别为嵌入调用并正确处理,类似于以下可以正常工作的 cURL 请求: curl -X POST http://192.168.10.170:1234/v1/embeddings \ -H "Content-Type: application/json" \ -H "Authorization: Bearer lm-studio" \ -d '{ "model": "bge-large-zh", "input": ["hi"], "max_tokens": 1 }'

image

实际行为

API 将请求视为聊天模型调用,并返回 400 状态码和以下错误: [2024-06-11 09:55:05.972] [ERROR] 'input' field is required

其他信息

•   环境: 使用 Docker 搭建 lmstudio
•   日志:[2024-06-11 09:55:05.968] [INFO] Received POST request to /v1/embeddings with body: {

"model": "bge-large-zh", "messages": [ { "role": "user", "content": "hi" } ], "max_tokens": 1 } [2024-06-11 09:55:05.972] [ERROR] 'input' field is required

建议改进

允许在配置中指定自定义渠道是用于嵌入请求还是聊天模型,或者根据 Base URL 自动检测请求类型。

ws02589111 commented 2 months ago

Same issue