diff --git a/pkg/api/http/controller/groups/provider/requesters.py b/pkg/api/http/controller/groups/provider/requesters.py index 7dd3cfea..18939d32 100644 --- a/pkg/api/http/controller/groups/provider/requesters.py +++ b/pkg/api/http/controller/groups/provider/requesters.py @@ -24,3 +24,17 @@ class RequestersRouterGroup(group.RouterGroup): return self.success(data={ 'requester': requester_info }) + + @self.route('//icon', methods=['GET']) + async def _(requester_name: str) -> quart.Response: + requester_manifest = self.ap.model_mgr.get_available_requester_manifest_by_name(requester_name) + + if requester_manifest is None: + return self.http_status(404, -1, 'requester not found') + + icon_path = requester_manifest.icon_rel_path + + if icon_path is None: + return self.http_status(404, -1, 'icon not found') + + return await quart.send_file(icon_path) diff --git a/pkg/discover/engine.py b/pkg/discover/engine.py index 2b83ef72..e79a97ad 100644 --- a/pkg/discover/engine.py +++ b/pkg/discover/engine.py @@ -4,7 +4,7 @@ import typing import importlib import os import inspect - +import mimetypes import yaml import pydantic @@ -154,6 +154,11 @@ class Component(pydantic.BaseModel): """组件可执行文件信息""" return self._execution + @property + def icon_rel_path(self) -> str: + """图标相对路径""" + return os.path.join(self.rel_dir, self.metadata.icon) if self.metadata.icon is not None and self.metadata.icon.strip() != '' else None + def get_python_component_class(self) -> typing.Type[typing.Any]: """获取Python组件类""" module_path = os.path.join(self.rel_dir, self.execution.python.path) diff --git a/pkg/provider/modelmgr/modelmgr.py b/pkg/provider/modelmgr/modelmgr.py index 41e97f3e..244d5753 100644 --- a/pkg/provider/modelmgr/modelmgr.py +++ b/pkg/provider/modelmgr/modelmgr.py @@ -135,6 +135,13 @@ class ModelManager: if component.metadata.name == name: return component.to_plain_dict() return None + + def get_available_requester_manifest_by_name(self, name: str) -> engine.Component | None: + """通过名称获取请求器清单""" + for component in self.requester_components: + if component.metadata.name == name: + return component + return None async def invoke_llm( self, diff --git a/pkg/provider/modelmgr/requesters/anthropic.svg b/pkg/provider/modelmgr/requesters/anthropic.svg new file mode 100644 index 00000000..d852f044 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/anthropic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/pkg/provider/modelmgr/requesters/anthropicmsgs.yaml b/pkg/provider/modelmgr/requesters/anthropicmsgs.yaml index 6d1a53cf..07aca1fe 100644 --- a/pkg/provider/modelmgr/requesters/anthropicmsgs.yaml +++ b/pkg/provider/modelmgr/requesters/anthropicmsgs.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: Anthropic zh_CN: Anthropic + icon: anthropic.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/bailian.png b/pkg/provider/modelmgr/requesters/bailian.png new file mode 100644 index 00000000..c1aff40e Binary files /dev/null and b/pkg/provider/modelmgr/requesters/bailian.png differ diff --git a/pkg/provider/modelmgr/requesters/bailianchatcmpl.yaml b/pkg/provider/modelmgr/requesters/bailianchatcmpl.yaml index 136e903f..f288df53 100644 --- a/pkg/provider/modelmgr/requesters/bailianchatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/bailianchatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: Aliyun Bailian zh_CN: 阿里云百炼 + icon: bailian.png spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/chatcmpl.yaml b/pkg/provider/modelmgr/requesters/chatcmpl.yaml index a67e23d1..bbf31e9a 100644 --- a/pkg/provider/modelmgr/requesters/chatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/chatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: OpenAI zh_CN: OpenAI + icon: openai.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/deepseek.svg b/pkg/provider/modelmgr/requesters/deepseek.svg new file mode 100644 index 00000000..aa854a75 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/deepseek.svg @@ -0,0 +1,3 @@ + + + diff --git a/pkg/provider/modelmgr/requesters/deepseekchatcmpl.yaml b/pkg/provider/modelmgr/requesters/deepseekchatcmpl.yaml index 9890e21e..48095697 100644 --- a/pkg/provider/modelmgr/requesters/deepseekchatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/deepseekchatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: DeepSeek zh_CN: 深度求索 + icon: deepseek.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/giteeai.svg b/pkg/provider/modelmgr/requesters/giteeai.svg new file mode 100644 index 00000000..1f51187f --- /dev/null +++ b/pkg/provider/modelmgr/requesters/giteeai.svg @@ -0,0 +1,3 @@ + + + diff --git a/pkg/provider/modelmgr/requesters/giteeaichatcmpl.yaml b/pkg/provider/modelmgr/requesters/giteeaichatcmpl.yaml index 3e4efd61..22d48501 100644 --- a/pkg/provider/modelmgr/requesters/giteeaichatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/giteeaichatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: Gitee AI zh_CN: Gitee AI + icon: giteeai.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/lmstudio.webp b/pkg/provider/modelmgr/requesters/lmstudio.webp new file mode 100644 index 00000000..66bc8163 Binary files /dev/null and b/pkg/provider/modelmgr/requesters/lmstudio.webp differ diff --git a/pkg/provider/modelmgr/requesters/lmstudiochatcmpl.yaml b/pkg/provider/modelmgr/requesters/lmstudiochatcmpl.yaml index 219e5839..a1e02584 100644 --- a/pkg/provider/modelmgr/requesters/lmstudiochatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/lmstudiochatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: LM Studio zh_CN: LM Studio + icon: lmstudio.webp spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/moonshot.png b/pkg/provider/modelmgr/requesters/moonshot.png new file mode 100644 index 00000000..58ba4b46 Binary files /dev/null and b/pkg/provider/modelmgr/requesters/moonshot.png differ diff --git a/pkg/provider/modelmgr/requesters/moonshotchatcmpl.yaml b/pkg/provider/modelmgr/requesters/moonshotchatcmpl.yaml index 7290784f..7e50130e 100644 --- a/pkg/provider/modelmgr/requesters/moonshotchatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/moonshotchatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: Moonshot zh_CN: 月之暗面 + icon: moonshot.png spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/ollama.svg b/pkg/provider/modelmgr/requesters/ollama.svg new file mode 100644 index 00000000..f8482a96 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/ollama.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/pkg/provider/modelmgr/requesters/ollamachat.yaml b/pkg/provider/modelmgr/requesters/ollamachat.yaml index ba915aeb..c62cb1ea 100644 --- a/pkg/provider/modelmgr/requesters/ollamachat.yaml +++ b/pkg/provider/modelmgr/requesters/ollamachat.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: Ollama zh_CN: Ollama + icon: ollama.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/openai.svg b/pkg/provider/modelmgr/requesters/openai.svg new file mode 100644 index 00000000..70686f9b --- /dev/null +++ b/pkg/provider/modelmgr/requesters/openai.svg @@ -0,0 +1,4 @@ + + + + diff --git a/pkg/provider/modelmgr/requesters/siliconflow.svg b/pkg/provider/modelmgr/requesters/siliconflow.svg new file mode 100644 index 00000000..ad6b384f --- /dev/null +++ b/pkg/provider/modelmgr/requesters/siliconflow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pkg/provider/modelmgr/requesters/siliconflowchatcmpl.yaml b/pkg/provider/modelmgr/requesters/siliconflowchatcmpl.yaml index c938b21c..c8dfe770 100644 --- a/pkg/provider/modelmgr/requesters/siliconflowchatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/siliconflowchatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: SiliconFlow zh_CN: 硅基流动 + icon: siliconflow.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/volcark.svg b/pkg/provider/modelmgr/requesters/volcark.svg new file mode 100644 index 00000000..e6454a89 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/volcark.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pkg/provider/modelmgr/requesters/volcarkchatcmpl.yaml b/pkg/provider/modelmgr/requesters/volcarkchatcmpl.yaml index 56347bc5..bc639b86 100644 --- a/pkg/provider/modelmgr/requesters/volcarkchatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/volcarkchatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: Volc Engine Ark zh_CN: 火山方舟 + icon: volcark.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/xai.svg b/pkg/provider/modelmgr/requesters/xai.svg new file mode 100644 index 00000000..f8b745cb --- /dev/null +++ b/pkg/provider/modelmgr/requesters/xai.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pkg/provider/modelmgr/requesters/xaichatcmpl.yaml b/pkg/provider/modelmgr/requesters/xaichatcmpl.yaml index 604b88c6..99588dab 100644 --- a/pkg/provider/modelmgr/requesters/xaichatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/xaichatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: xAI zh_CN: xAI + icon: xai.svg spec: config: - name: base_url diff --git a/pkg/provider/modelmgr/requesters/zhipuai.svg b/pkg/provider/modelmgr/requesters/zhipuai.svg new file mode 100644 index 00000000..016f97dd --- /dev/null +++ b/pkg/provider/modelmgr/requesters/zhipuai.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/pkg/provider/modelmgr/requesters/zhipuaichatcmpl.yaml b/pkg/provider/modelmgr/requesters/zhipuaichatcmpl.yaml index 20b8b496..68bc3fe3 100644 --- a/pkg/provider/modelmgr/requesters/zhipuaichatcmpl.yaml +++ b/pkg/provider/modelmgr/requesters/zhipuaichatcmpl.yaml @@ -5,6 +5,7 @@ metadata: label: en_US: ZhipuAI zh_CN: 智谱 AI + icon: zhipuai.svg spec: config: - name: base_url