Skip to content

Conversation

@Soulter
Copy link
Member

@Soulter Soulter commented Dec 31, 2025

  • 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.

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

为 provider 的 extra_body 配置添加基于模板 schema 的编辑功能,并改进用于已类型化参数的配置编辑器界面。

New Features:

  • 在对象编辑器中为字典配置项提供模板 schema 支持,包括带有默认值和类型元数据的预定义字段,如 temperaturetop_pmax_tokens
  • 在配置编辑器中以模板方式暴露数值型参数,可选使用滑杆,并对 intfloatbooljson 值进行类型感知转换。
  • 在模型面板中添加专用的 provider 配置按钮,以便快速打开 provider 编辑对话框。

Enhancements:

  • 在对象编辑器中将基于模板的字段与常规键值对分离,以提供更清晰的展示和更安全的编辑体验。
  • 改进配置编辑器中模板字段的空状态处理和视觉样式。
  • 通过按键名而非索引删除条目,使对象编辑器中的键删除操作更健壮。

Chores:

  • 更新本地化资源,以覆盖新的 provider 配置操作和标签。
Original summary in English

Summary by Sourcery

Add template schema–driven editing for provider extra_body configuration and improve the configuration editor UI for typed parameters.

New Features:

  • Support template schemas for dict configuration items in the object editor, including predefined fields like temperature, top_p, and max_tokens with defaults and type metadata.
  • Expose template-based numeric parameters in the configuration editor with optional sliders and type-aware conversion for int, float, bool, and json values.
  • Add a dedicated provider configuration button in the models panel to quickly open the provider edit dialog.

Enhancements:

  • Separate template-based fields from regular key-value pairs in the object editor for clearer presentation and safer editing.
  • Improve empty-state handling and visual styling for template fields in the configuration editor.
  • Make key removal in the object editor more robust by removing entries by key instead of by index.

Chores:

  • Update localization resources to cover new provider configuration actions and labels.

新功能:

  • 支持使用模板 schema 编辑字典配置项,包括 temperaturetop_pmax_tokens 等预定义字段,并提供默认值和类型处理。
  • 在配置编辑器 UI 中暴露基于模板的数值参数,可选使用滑块,并支持按类型进行转换(intfloatbooljson)。
  • 在提供商模型面板中添加独立的配置按钮,用于快速打开提供商编辑对话框。

增强:

  • 在对象编辑器中将基于模板的字段与常规键值对分离,提升清晰度并防止无意修改。
  • 改进配置编辑器中模板字段的空状态处理和视觉样式。
  • 更新对象编辑器中的键移除逻辑,从基于索引改为基于键,以实现更健壮的操作。

杂务:

  • 更新本地化资源,以涵盖新的提供商配置操作和标签。
Original summary in English

Summary by Sourcery

为 provider 的 extra_body 配置添加基于模板 schema 的编辑功能,并改进用于已类型化参数的配置编辑器界面。

New Features:

  • 在对象编辑器中为字典配置项提供模板 schema 支持,包括带有默认值和类型元数据的预定义字段,如 temperaturetop_pmax_tokens
  • 在配置编辑器中以模板方式暴露数值型参数,可选使用滑杆,并对 intfloatbooljson 值进行类型感知转换。
  • 在模型面板中添加专用的 provider 配置按钮,以便快速打开 provider 编辑对话框。

Enhancements:

  • 在对象编辑器中将基于模板的字段与常规键值对分离,以提供更清晰的展示和更安全的编辑体验。
  • 改进配置编辑器中模板字段的空状态处理和视觉样式。
  • 通过按键名而非索引删除条目,使对象编辑器中的键删除操作更健壮。

Chores:

  • 更新本地化资源,以覆盖新的 provider 配置操作和标签。
Original summary in English

Summary by Sourcery

Add template schema–driven editing for provider extra_body configuration and improve the configuration editor UI for typed parameters.

New Features:

  • Support template schemas for dict configuration items in the object editor, including predefined fields like temperature, top_p, and max_tokens with defaults and type metadata.
  • Expose template-based numeric parameters in the configuration editor with optional sliders and type-aware conversion for int, float, bool, and json values.
  • Add a dedicated provider configuration button in the models panel to quickly open the provider edit dialog.

Enhancements:

  • Separate template-based fields from regular key-value pairs in the object editor for clearer presentation and safer editing.
  • Improve empty-state handling and visual styling for template fields in the configuration editor.
  • Make key removal in the object editor more robust by removing entries by key instead of by index.

Chores:

  • Update localization resources to cover new provider configuration actions and labels.

…I improvements

- 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.
@auto-assign auto-assign bot requested review from Raven95676 and anka-afk December 31, 2025 04:16
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. area:webui The bug / feature is about webui(dashboard) of astrbot. labels Dec 31, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 2 个问题,并给出了一些整体性的反馈:

  • 在普通键值对和模板字段之间存在不少重复的类型处理逻辑(string/number/boolean + slider 和转换分支);可以考虑把这些逻辑集中到共享的 helper 或一个小的子组件中,以降低复杂度并保持行为一致。
  • 当前值的类型系统(string/number/float/int/bool/boolean/json)是通过分散在初始化、UI 渲染以及 confirmDialog 转换中的字符串字面量来表达的;你可以通过定义一个统一的映射或类 enum 结构来同时驱动展示和序列化,让这部分更健壮。
  • :style="pair.slider ? 'max-width: 120px;' : ''" 和模板字段的透明度样式这样的内联样式,如果改成命名的 CSS 工具类而不是字符串形式的内联样式,会更易于维护和调整。
给 AI Agent 的提示词
Please address the comments from this code review:

## Overall Comments
- 在普通键值对和模板字段之间存在不少重复的类型处理逻辑(string/number/boolean + slider 和转换分支);可以考虑把这些逻辑集中到共享的 helper 或一个小的子组件中,以降低复杂度并保持行为一致。
- 当前值的类型系统(string/number/float/int/bool/boolean/json)是通过分散在初始化、UI 渲染以及 confirmDialog 转换中的字符串字面量来表达的;你可以通过定义一个统一的映射或类 enum 结构来同时驱动展示和序列化,让这部分更健壮。
-`:style="pair.slider ? 'max-width: 120px;' : ''"` 和模板字段的透明度样式这样的内联样式,如果改成命名的 CSS 工具类而不是字符串形式的内联样式,会更易于维护和调整。

## Individual Comments

### Comment 1
<location> `dashboard/src/components/shared/ObjectEditor.vue:30-31` </location>
<code_context>
-          <div v-for="(pair, index) in localKeyValuePairs" :key="index" class="key-value-pair">
+        <!-- Regular key-value pairs (non-template) -->
+        <div v-if="nonTemplatePairs.length > 0">
+          <div v-for="(pair, index) in nonTemplatePairs" :key="index" class="key-value-pair">
             <v-row no-gutters align="center" class="mb-2">
               <v-col cols="4">
</code_context>

<issue_to_address>
**suggestion (bug_risk):** 请为 v-for 列表使用稳定的 key(例如 pair.key),而不是索引。

因为这个列表现在是从 `nonTemplatePairs` 派生出来的,并且删除操作是通过 key(`removeKeyValuePairByKey(pair.key)`)进行的,如果仍然用数组索引作为 `:key`,在条目重排或删除时就有可能出现 DOM 更新错位。把 `:key` 绑定到 `pair.key`(或其他稳定的唯一 ID)可以让 DOM 复用和底层数据保持正确对应。

```suggestion
        <div v-if="nonTemplatePairs.length > 0">
          <div v-for="(pair, index) in nonTemplatePairs" :key="pair.key" class="key-value-pair">
```
</issue_to_address>

### Comment 2
<location> `dashboard/src/components/shared/ObjectEditor.vue:130` </location>
<code_context>
+                  hide-details
+                  placeholder="字符串值"
+                ></v-text-field>
+                <div v-else-if="template.type === 'number' || template.type === 'float' || template.type === 'int'" class="d-flex align-center ga-4 flex-grow-1">
+                  <v-slider
+                    v-if="template.slider"
</code_context>

<issue_to_address>
**issue (typo):** `ga-4` 这个 class 名看起来像是个拼写错误,可能不会产生任何效果。

在其它地方你使用的是 `gap-2`(例如 `class="d-flex align-center gap-2 flex-grow-1"`),但这里是 `ga-4`,这和常见的工具类命名不符,很可能本意是 `gap-4`。请确认并进行调整,以保持间距的一致性。

```suggestion
                <div v-else-if="template.type === 'number' || template.type === 'float' || template.type === 'int'" class="d-flex align-center gap-4 flex-grow-1">
```
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • There is quite a bit of duplicated type-handling logic between regular key-value pairs and template fields (string/number/boolean + slider and conversion branches); consider centralizing this into shared helpers or a small subcomponent to reduce complexity and keep behavior consistent.
  • The type system for values (string/number/float/int/bool/boolean/json) is currently encoded as scattered string literals across initialization, UI rendering, and confirmDialog conversion; you could make this more robust by defining a single mapping or enum-like structure to drive both display and serialization.
  • Inline styles like :style="pair.slider ? 'max-width: 120px;' : ''" and the template-field opacity styling would be easier to maintain and tweak if moved into named CSS utility classes instead of string-based inline styles.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There is quite a bit of duplicated type-handling logic between regular key-value pairs and template fields (string/number/boolean + slider and conversion branches); consider centralizing this into shared helpers or a small subcomponent to reduce complexity and keep behavior consistent.
- The type system for values (string/number/float/int/bool/boolean/json) is currently encoded as scattered string literals across initialization, UI rendering, and confirmDialog conversion; you could make this more robust by defining a single mapping or enum-like structure to drive both display and serialization.
- Inline styles like `:style="pair.slider ? 'max-width: 120px;' : ''"` and the template-field opacity styling would be easier to maintain and tweak if moved into named CSS utility classes instead of string-based inline styles.

## Individual Comments

### Comment 1
<location> `dashboard/src/components/shared/ObjectEditor.vue:30-31` </location>
<code_context>
-          <div v-for="(pair, index) in localKeyValuePairs" :key="index" class="key-value-pair">
+        <!-- Regular key-value pairs (non-template) -->
+        <div v-if="nonTemplatePairs.length > 0">
+          <div v-for="(pair, index) in nonTemplatePairs" :key="index" class="key-value-pair">
             <v-row no-gutters align="center" class="mb-2">
               <v-col cols="4">
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Use a stable key (e.g., pair.key) instead of the index for the v-for list.

Because this list is now derived from `nonTemplatePairs` and deletions work by key (`removeKeyValuePairByKey(pair.key)`), using the array index as the `:key` risks mismatched DOM updates when items are reordered or removed. Binding `:key` to `pair.key` (or another stable unique ID) keeps DOM reuse correctly aligned with the underlying data.

```suggestion
        <div v-if="nonTemplatePairs.length > 0">
          <div v-for="(pair, index) in nonTemplatePairs" :key="pair.key" class="key-value-pair">
```
</issue_to_address>

### Comment 2
<location> `dashboard/src/components/shared/ObjectEditor.vue:130` </location>
<code_context>
+                  hide-details
+                  placeholder="字符串值"
+                ></v-text-field>
+                <div v-else-if="template.type === 'number' || template.type === 'float' || template.type === 'int'" class="d-flex align-center ga-4 flex-grow-1">
+                  <v-slider
+                    v-if="template.slider"
</code_context>

<issue_to_address>
**issue (typo):** The `ga-4` class name looks like a typo and may not have any effect.

In other places you use `gap-2` (e.g. `class="d-flex align-center gap-2 flex-grow-1"), but here it's `ga-4`, which doesn’t match standard utility classes and is likely meant to be `gap-4`. Please confirm and adjust for consistent spacing.

```suggestion
                <div v-else-if="template.type === 'number' || template.type === 'float' || template.type === 'int'" class="d-flex align-center gap-4 flex-grow-1">
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +30 to +31
<div v-if="nonTemplatePairs.length > 0">
<div v-for="(pair, index) in nonTemplatePairs" :key="index" class="key-value-pair">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): 请为 v-for 列表使用稳定的 key(例如 pair.key),而不是索引。

因为这个列表现在是从 nonTemplatePairs 派生出来的,并且删除操作是通过 key(removeKeyValuePairByKey(pair.key))进行的,如果仍然用数组索引作为 :key,在条目重排或删除时就有可能出现 DOM 更新错位。把 :key 绑定到 pair.key(或其他稳定的唯一 ID)可以让 DOM 复用和底层数据保持正确对应。

Suggested change
<div v-if="nonTemplatePairs.length > 0">
<div v-for="(pair, index) in nonTemplatePairs" :key="index" class="key-value-pair">
<div v-if="nonTemplatePairs.length > 0">
<div v-for="(pair, index) in nonTemplatePairs" :key="pair.key" class="key-value-pair">
Original comment in English

suggestion (bug_risk): Use a stable key (e.g., pair.key) instead of the index for the v-for list.

Because this list is now derived from nonTemplatePairs and deletions work by key (removeKeyValuePairByKey(pair.key)), using the array index as the :key risks mismatched DOM updates when items are reordered or removed. Binding :key to pair.key (or another stable unique ID) keeps DOM reuse correctly aligned with the underlying data.

Suggested change
<div v-if="nonTemplatePairs.length > 0">
<div v-for="(pair, index) in nonTemplatePairs" :key="index" class="key-value-pair">
<div v-if="nonTemplatePairs.length > 0">
<div v-for="(pair, index) in nonTemplatePairs" :key="pair.key" class="key-value-pair">

@Soulter Soulter merged commit f156add into master Dec 31, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants