Skip to content

Commit f156add

Browse files
authored
feat: enhance configuration editor with template schema support and UI improvements (#4267)
- Added support for template schemas in the configuration editor, allowing users to define and manage additional parameters like temperature, top_p, and max_tokens. - Improved UI components in ProviderModelsPanel and ObjectEditor for better user interaction, including new configuration buttons and enhanced input handling. - Updated localization files to include new configuration options.
1 parent b5a4b80 commit f156add

6 files changed

Lines changed: 269 additions & 20 deletions

File tree

astrbot/core/config/default.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,32 @@ class ChatProviderTemplate(TypedDict):
14511451
"description": "自定义请求体参数",
14521452
"type": "dict",
14531453
"items": {},
1454-
"hint": "此处添加的键值对将被合并到发送给 API 的 extra_body 中。值可以是字符串、数字或布尔值。",
1454+
"hint": "用于在请求时添加额外的参数,如 temperature、top_p、max_tokens 等。",
1455+
"template_schema": {
1456+
"temperature": {
1457+
"name": "Temperature",
1458+
"description": "温度参数",
1459+
"hint": "控制输出的随机性,范围通常为 0-2。值越高越随机。",
1460+
"type": "float",
1461+
"default": 0.6,
1462+
"slider": {"min": 0, "max": 2, "step": 0.1},
1463+
},
1464+
"top_p": {
1465+
"name": "Top-p",
1466+
"description": "Top-p 采样",
1467+
"hint": "核采样参数,范围通常为 0-1。控制模型考虑的概率质量。",
1468+
"type": "float",
1469+
"default": 1.0,
1470+
"slider": {"min": 0, "max": 1, "step": 0.01},
1471+
},
1472+
"max_tokens": {
1473+
"name": "Max Tokens",
1474+
"description": "最大令牌数",
1475+
"hint": "生成的最大令牌数。",
1476+
"type": "int",
1477+
"default": 8192,
1478+
},
1479+
},
14551480
},
14561481
"provider": {
14571482
"type": "string",

dashboard/src/components/provider/ProviderModelsPanel.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
{{ tm('availability.test') }}
8383
<template #activator="{ props }">
8484
<v-btn
85-
icon="mdi-wrench"
85+
icon="mdi-connection"
8686
size="small"
8787
variant="text"
8888
:disabled="!entry.provider.enable"
@@ -93,6 +93,19 @@
9393
</template>
9494
</v-tooltip>
9595

96+
<v-tooltip location="top" max-width="300">
97+
{{ tm('models.configure') }}
98+
<template #activator="{ props }">
99+
<v-btn
100+
icon="mdi-cog"
101+
size="small"
102+
variant="text"
103+
v-bind="props"
104+
@click.stop="emit('open-provider-edit', entry.provider)"
105+
></v-btn>
106+
</template>
107+
</v-tooltip>
108+
96109
<v-btn icon="mdi-delete" size="small" variant="text" color="error" @click.stop="emit('delete-provider', entry.provider)"></v-btn>
97110
</div>
98111
</template>

dashboard/src/components/shared/ConfigItemRenderer.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
<ObjectEditor
189189
v-else-if="itemMeta?.type === 'dict'"
190190
:model-value="modelValue"
191+
:item-meta="itemMeta"
191192
@update:model-value="emitUpdate"
192193
class="config-field"
193194
/>

0 commit comments

Comments
 (0)