-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.enhancementNew feature or requestNew feature or request
Description
Description / 描述
增加智谱Embedding模型和Rerank模型支持
在AstrBot的“新增模型提供商”,关于Embedding模型和Rerank模型现有的添加选项中:
-
Embedding的Url会自动补全
/v1(openai)或者/v1beta(gemini),而智谱的Embedding模型调用Url为https://open.bigmodel.cn/api/paas/v4/embeddings -
Rerank的Url则会自动补全
/v1/rerank(vllm, xinference, bailian),而智谱的Rerank模型调用Url为https://open.bigmodel.cn/api/paas/v4/rerank
这使得智谱的模型在Embedding模型和Rerank模型无法被成功添加。
希望在之后可以增加对智谱Embedding模型和Rerank模型的支持;或者可以增加一个必须输入完整Url的空配置,允许用户自行设置。
AstrBot版本:v4.18.3
根据智谱的API文档 (https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E5%B5%8C%E5%85%A5) 和OpenAI的API文档 (https://developers.openai.com/api/docs/guides/embeddings/?lang=python) 来看,两者在Embedding的POST和结果上的结构是高度一致的:
# openai_embedding_post
curl https://api.openai.com/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"input": "Your text string goes here",
"model": "text-embedding-3-small"
}'
# zhipu_embedding_post
curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "embedding-3",
"input": "你好,今天天气怎么样.",
"dimensions": 2
}
'
# openai_embedding_result
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
-0.006929283495992422, -0.005336422007530928, -4.547132266452536e-5,
-0.024047505110502243
]
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 5,
"total_tokens": 5
}
}
#zhipu_embedding_result
{
"model": "<string>",
"object": "list",
"data": [
{
"index": 123,
"object": "embedding",
"embedding": [
123
]
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}
智谱的Embedding模型理论上可以以OpenAI兼容接口进行调用。
Use Case / 使用场景
No response
Willing to Submit PR? / 是否愿意提交PR?
- Yes, I am willing to submit a PR. / 是的,我愿意提交 PR。
Code of Conduct
- I have read and agree to abide by the project's Code of Conduct. /
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.enhancementNew feature or requestNew feature or request