Skip to content

Commit 69435c0

Browse files
authored
feat: add logo for requesters (#1300)
1 parent 2fdb53e commit 69435c0

27 files changed

+86
-1
lines changed

pkg/api/http/controller/groups/provider/requesters.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,17 @@ async def _(requester_name: str) -> quart.Response:
2424
return self.success(data={
2525
'requester': requester_info
2626
})
27+
28+
@self.route('/<requester_name>/icon', methods=['GET'])
29+
async def _(requester_name: str) -> quart.Response:
30+
requester_manifest = self.ap.model_mgr.get_available_requester_manifest_by_name(requester_name)
31+
32+
if requester_manifest is None:
33+
return self.http_status(404, -1, 'requester not found')
34+
35+
icon_path = requester_manifest.icon_rel_path
36+
37+
if icon_path is None:
38+
return self.http_status(404, -1, 'icon not found')
39+
40+
return await quart.send_file(icon_path)

pkg/discover/engine.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import importlib
55
import os
66
import inspect
7-
7+
import mimetypes
88
import yaml
99
import pydantic
1010

@@ -154,6 +154,11 @@ def execution(self) -> Execution:
154154
"""组件可执行文件信息"""
155155
return self._execution
156156

157+
@property
158+
def icon_rel_path(self) -> str:
159+
"""图标相对路径"""
160+
return os.path.join(self.rel_dir, self.metadata.icon) if self.metadata.icon is not None and self.metadata.icon.strip() != '' else None
161+
157162
def get_python_component_class(self) -> typing.Type[typing.Any]:
158163
"""获取Python组件类"""
159164
module_path = os.path.join(self.rel_dir, self.execution.python.path)

pkg/provider/modelmgr/modelmgr.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ def get_available_requester_info_by_name(self, name: str) -> dict | None:
135135
if component.metadata.name == name:
136136
return component.to_plain_dict()
137137
return None
138+
139+
def get_available_requester_manifest_by_name(self, name: str) -> engine.Component | None:
140+
"""通过名称获取请求器清单"""
141+
for component in self.requester_components:
142+
if component.metadata.name == name:
143+
return component
144+
return None
138145

139146
async def invoke_llm(
140147
self,
Lines changed: 4 additions & 0 deletions
Loading

pkg/provider/modelmgr/requesters/anthropicmsgs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
label:
66
en_US: Anthropic
77
zh_CN: Anthropic
8+
icon: anthropic.svg
89
spec:
910
config:
1011
- name: base_url
2.77 KB
Loading

pkg/provider/modelmgr/requesters/bailianchatcmpl.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
label:
66
en_US: Aliyun Bailian
77
zh_CN: 阿里云百炼
8+
icon: bailian.png
89
spec:
910
config:
1011
- name: base_url

pkg/provider/modelmgr/requesters/chatcmpl.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
label:
66
en_US: OpenAI
77
zh_CN: OpenAI
8+
icon: openai.svg
89
spec:
910
config:
1011
- name: base_url
Lines changed: 3 additions & 0 deletions
Loading

pkg/provider/modelmgr/requesters/deepseekchatcmpl.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
label:
66
en_US: DeepSeek
77
zh_CN: 深度求索
8+
icon: deepseek.svg
89
spec:
910
config:
1011
- name: base_url

0 commit comments

Comments
 (0)