mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 17:47:06 +08:00
* feat: 适配 coze 供应商 1. 支持文件上传 2. 支持多模态 3. 支持流式传输 4. 支持 API 端的上下文保存历史记录 5. 支持类似 dify 的 forget 接口 * style: format code * fix: type checking error * fix: 修复: 1. 使用coze api端的上下文时, 现在不会重复传递上下文 2. 使用 AstrBot 的上下文时, 正确处理其中的图片信息 3. 上传图片时, 提供一个非持久化的缓存避免重复上传(在解析上下文并将文件转化为file_id传递给coze api时, 如果没有缓存会导致很多的网络资源浪费) 4. 修复reset等指令不能正确重置上下文的问题 * fix: 移除某些地方多余的针对 dify 的断言, 以兼容 Coze * style: 修改配置项显示/webchat平台对于非预期的类型的处理 * fix: 让conversation_id放到请求中正确的位置 * refactor: extract coze api client * refactor: improve image processing logic in ProviderCoze * chore: remove file ext guessing --------- Co-authored-by: Soulter <905617992@qq.com>
53 lines
3.1 KiB
JavaScript
53 lines
3.1 KiB
JavaScript
/**
|
|
* 提供商相关的工具函数
|
|
*/
|
|
|
|
/**
|
|
* 获取提供商类型对应的图标
|
|
* @param {string} type - 提供商类型
|
|
* @returns {string} 图标 URL
|
|
*/
|
|
export function getProviderIcon(type) {
|
|
const icons = {
|
|
'openai': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/openai.svg',
|
|
'azure': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/azure.svg',
|
|
'xai': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/xai.svg',
|
|
'anthropic': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/anthropic.svg',
|
|
'ollama': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/ollama.svg',
|
|
'google': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/gemini-color.svg',
|
|
'deepseek': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek.svg',
|
|
'modelscope': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/modelscope.svg',
|
|
'zhipu': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/zhipu.svg',
|
|
'siliconflow': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/siliconcloud.svg',
|
|
'moonshot': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/kimi.svg',
|
|
'ppio': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/ppio.svg',
|
|
'dify': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/dify-color.svg',
|
|
"coze": "https://registry.npmmirror.com/@lobehub/icons-static-svg/1.66.0/files/icons/coze.svg",
|
|
'dashscope': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/alibabacloud-color.svg',
|
|
'fastgpt': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/fastgpt-color.svg',
|
|
'lm_studio': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/lmstudio.svg',
|
|
'fishaudio': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/fishaudio.svg',
|
|
'minimax': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/minimax.svg',
|
|
'302ai': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/1.53.0/files/icons/ai302-color.svg',
|
|
'microsoft': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/microsoft.svg',
|
|
'vllm': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vllm.svg',
|
|
};
|
|
return icons[type] || '';
|
|
}
|
|
|
|
/**
|
|
* 获取提供商简介
|
|
* @param {Object} template - 模板对象
|
|
* @param {string} name - 提供商名称
|
|
* @param {Function} tm - 翻译函数
|
|
* @returns {string} 提供商描述
|
|
*/
|
|
export function getProviderDescription(template, name, tm) {
|
|
if (name == 'OpenAI') {
|
|
return tm('providers.description.openai', { type: template.type });
|
|
} else if (name == 'vLLM Rerank') {
|
|
return tm('providers.description.vllm_rerank', { type: template.type });
|
|
}
|
|
return tm('providers.description.default', { type: template.type });
|
|
}
|