feat(web): Tool feedback on UI (#1933)
* feat(web): tool feedback * feat(web): tool feedback * fix test
This commit is contained in:
parent
69cf9342e1
commit
aa3300c1bd
5 changed files with 57 additions and 0 deletions
|
|
@ -155,6 +155,11 @@ export function ConfigPage() {
|
||||||
"Max tool iterations",
|
"Max tool iterations",
|
||||||
{ min: 1 },
|
{ min: 1 },
|
||||||
)
|
)
|
||||||
|
const toolFeedbackMaxArgsLength = parseIntField(
|
||||||
|
form.toolFeedbackMaxArgsLength,
|
||||||
|
"Tool feedback max args length",
|
||||||
|
{ min: 0 },
|
||||||
|
)
|
||||||
const summarizeMessageThreshold = parseIntField(
|
const summarizeMessageThreshold = parseIntField(
|
||||||
form.summarizeMessageThreshold,
|
form.summarizeMessageThreshold,
|
||||||
"Summarize message threshold",
|
"Summarize message threshold",
|
||||||
|
|
@ -203,6 +208,10 @@ export function ConfigPage() {
|
||||||
defaults: {
|
defaults: {
|
||||||
workspace,
|
workspace,
|
||||||
restrict_to_workspace: form.restrictToWorkspace,
|
restrict_to_workspace: form.restrictToWorkspace,
|
||||||
|
tool_feedback: {
|
||||||
|
enabled: form.toolFeedbackEnabled,
|
||||||
|
max_args_length: toolFeedbackMaxArgsLength,
|
||||||
|
},
|
||||||
max_tokens: maxTokens,
|
max_tokens: maxTokens,
|
||||||
context_window: contextWindow,
|
context_window: contextWindow,
|
||||||
max_tool_iterations: maxToolIterations,
|
max_tool_iterations: maxToolIterations,
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,33 @@ export function AgentDefaultsSection({
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SwitchCardField
|
||||||
|
label={t("pages.config.tool_feedback_enabled")}
|
||||||
|
hint={t("pages.config.tool_feedback_enabled_hint")}
|
||||||
|
layout="setting-row"
|
||||||
|
checked={form.toolFeedbackEnabled}
|
||||||
|
onCheckedChange={(checked) =>
|
||||||
|
onFieldChange("toolFeedbackEnabled", checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{form.toolFeedbackEnabled && (
|
||||||
|
<Field
|
||||||
|
label={t("pages.config.tool_feedback_max_args_length")}
|
||||||
|
hint={t("pages.config.tool_feedback_max_args_length_hint")}
|
||||||
|
layout="setting-row"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
value={form.toolFeedbackMaxArgsLength}
|
||||||
|
onChange={(e) =>
|
||||||
|
onFieldChange("toolFeedbackMaxArgsLength", e.target.value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
label={t("pages.config.max_tokens")}
|
label={t("pages.config.max_tokens")}
|
||||||
hint={t("pages.config.max_tokens_hint")}
|
hint={t("pages.config.max_tokens_hint")}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ export type JsonRecord = Record<string, unknown>
|
||||||
export interface CoreConfigForm {
|
export interface CoreConfigForm {
|
||||||
workspace: string
|
workspace: string
|
||||||
restrictToWorkspace: boolean
|
restrictToWorkspace: boolean
|
||||||
|
toolFeedbackEnabled: boolean
|
||||||
|
toolFeedbackMaxArgsLength: string
|
||||||
execEnabled: boolean
|
execEnabled: boolean
|
||||||
allowRemote: boolean
|
allowRemote: boolean
|
||||||
enableDenyPatterns: boolean
|
enableDenyPatterns: boolean
|
||||||
|
|
@ -63,6 +65,8 @@ export const DM_SCOPE_OPTIONS = [
|
||||||
export const EMPTY_FORM: CoreConfigForm = {
|
export const EMPTY_FORM: CoreConfigForm = {
|
||||||
workspace: "",
|
workspace: "",
|
||||||
restrictToWorkspace: true,
|
restrictToWorkspace: true,
|
||||||
|
toolFeedbackEnabled: true,
|
||||||
|
toolFeedbackMaxArgsLength: "300",
|
||||||
execEnabled: true,
|
execEnabled: true,
|
||||||
allowRemote: true,
|
allowRemote: true,
|
||||||
enableDenyPatterns: true,
|
enableDenyPatterns: true,
|
||||||
|
|
@ -124,6 +128,7 @@ export function buildFormFromConfig(config: unknown): CoreConfigForm {
|
||||||
const tools = asRecord(root.tools)
|
const tools = asRecord(root.tools)
|
||||||
const cron = asRecord(tools.cron)
|
const cron = asRecord(tools.cron)
|
||||||
const exec = asRecord(tools.exec)
|
const exec = asRecord(tools.exec)
|
||||||
|
const toolFeedback = asRecord(defaults.tool_feedback)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
workspace: asString(defaults.workspace) || EMPTY_FORM.workspace,
|
workspace: asString(defaults.workspace) || EMPTY_FORM.workspace,
|
||||||
|
|
@ -131,6 +136,14 @@ export function buildFormFromConfig(config: unknown): CoreConfigForm {
|
||||||
defaults.restrict_to_workspace === undefined
|
defaults.restrict_to_workspace === undefined
|
||||||
? EMPTY_FORM.restrictToWorkspace
|
? EMPTY_FORM.restrictToWorkspace
|
||||||
: asBool(defaults.restrict_to_workspace),
|
: asBool(defaults.restrict_to_workspace),
|
||||||
|
toolFeedbackEnabled:
|
||||||
|
toolFeedback.enabled === undefined
|
||||||
|
? EMPTY_FORM.toolFeedbackEnabled
|
||||||
|
: asBool(toolFeedback.enabled),
|
||||||
|
toolFeedbackMaxArgsLength: asNumberString(
|
||||||
|
toolFeedback.max_args_length,
|
||||||
|
EMPTY_FORM.toolFeedbackMaxArgsLength,
|
||||||
|
),
|
||||||
execEnabled:
|
execEnabled:
|
||||||
exec.enabled === undefined
|
exec.enabled === undefined
|
||||||
? EMPTY_FORM.execEnabled
|
? EMPTY_FORM.execEnabled
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,10 @@
|
||||||
"workspace_hint": "Base directory for agent file operations.",
|
"workspace_hint": "Base directory for agent file operations.",
|
||||||
"restrict_workspace": "Restrict to Workspace",
|
"restrict_workspace": "Restrict to Workspace",
|
||||||
"restrict_workspace_hint": "Only allow file operations inside workspace.",
|
"restrict_workspace_hint": "Only allow file operations inside workspace.",
|
||||||
|
"tool_feedback_enabled": "Tool Feedback",
|
||||||
|
"tool_feedback_enabled_hint": "Send a short tool-call preview into the current chat before each tool execution.",
|
||||||
|
"tool_feedback_max_args_length": "Tool Feedback Args Preview Length",
|
||||||
|
"tool_feedback_max_args_length_hint": "Maximum number of argument characters shown in each tool feedback message. Set to 0 to use the default.",
|
||||||
"exec_enabled": "Allow Commands",
|
"exec_enabled": "Allow Commands",
|
||||||
"exec_enabled_hint": "Enable or disable command execution for the app. When disabled, no command requests will run.",
|
"exec_enabled_hint": "Enable or disable command execution for the app. When disabled, no command requests will run.",
|
||||||
"allow_remote": "Allow Remote Commands",
|
"allow_remote": "Allow Remote Commands",
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,10 @@
|
||||||
"workspace_hint": "智能体执行文件读写操作时使用的基础目录。",
|
"workspace_hint": "智能体执行文件读写操作时使用的基础目录。",
|
||||||
"restrict_workspace": "限制工作目录访问",
|
"restrict_workspace": "限制工作目录访问",
|
||||||
"restrict_workspace_hint": "仅允许在工作目录内执行文件操作。",
|
"restrict_workspace_hint": "仅允许在工作目录内执行文件操作。",
|
||||||
|
"tool_feedback_enabled": "工具反馈",
|
||||||
|
"tool_feedback_enabled_hint": "在每次执行工具前,先向当前会话发送一条简短的工具调用预览。",
|
||||||
|
"tool_feedback_max_args_length": "工具反馈参数预览长度",
|
||||||
|
"tool_feedback_max_args_length_hint": "每条工具反馈消息中展示的参数字符上限。设为 0 时使用默认值。",
|
||||||
"exec_enabled": "允许命令执行",
|
"exec_enabled": "允许命令执行",
|
||||||
"exec_enabled_hint": "控制应用是否允许执行命令。关闭后,所有命令请求都不会执行。",
|
"exec_enabled_hint": "控制应用是否允许执行命令。关闭后,所有命令请求都不会执行。",
|
||||||
"allow_remote": "允许远程命令执行",
|
"allow_remote": "允许远程命令执行",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue