feat: add autoAcceptedPlan to options

This commit is contained in:
Li Xin
2025-04-24 17:24:58 +08:00
parent cd6afcdd98
commit 1755128209
4 changed files with 29 additions and 1 deletions

View File

@@ -17,11 +17,14 @@ import {
FormMessage, FormMessage,
} from "~/components/ui/form"; } from "~/components/ui/form";
import { Input } from "~/components/ui/input"; import { Input } from "~/components/ui/input";
import { Label } from "~/components/ui/label";
import { Switch } from "~/components/ui/switch";
import type { SettingsState } from "~/core/store"; import type { SettingsState } from "~/core/store";
import type { Tab } from "./types"; import type { Tab } from "./types";
const generalFormSchema = z.object({ const generalFormSchema = z.object({
autoAcceptedPlan: z.boolean(),
maxPlanIterations: z.number().min(1, { maxPlanIterations: z.number().min(1, {
message: "Max plan iterations must be at least 1.", message: "Max plan iterations must be at least 1.",
}), }),
@@ -68,6 +71,26 @@ export const GeneralTab: Tab = ({
<main> <main>
<Form {...form}> <Form {...form}>
<form className="space-y-8"> <form className="space-y-8">
<FormField
control={form.control}
name="autoAcceptedPlan"
render={({ field }) => (
<FormItem>
<FormControl>
<div className="flex items-center gap-2">
<Switch
id="autoAcceptedPlan"
checked={field.value}
onCheckedChange={field.onChange}
/>
<Label className="text-sm" htmlFor="autoAcceptedPlan">
Auto accept plan
</Label>
</div>
</FormControl>
</FormItem>
)}
/>
<FormField <FormField
control={form.control} control={form.control}
name="maxPlanIterations" name="maxPlanIterations"

View File

@@ -12,6 +12,7 @@ export function chatStream(
userMessage: string, userMessage: string,
params: { params: {
thread_id: string; thread_id: string;
auto_accepted_plan: boolean;
max_plan_iterations: number; max_plan_iterations: number;
max_step_num: number; max_step_num: number;
interrupt_feedback?: string; interrupt_feedback?: string;
@@ -33,7 +34,6 @@ export function chatStream(
return fetchStream<ChatEvent>(resolveServiceURL("chat/stream"), { return fetchStream<ChatEvent>(resolveServiceURL("chat/stream"), {
body: JSON.stringify({ body: JSON.stringify({
messages: [{ role: "user", content: userMessage }], messages: [{ role: "user", content: userMessage }],
auto_accepted_plan: false,
...params, ...params,
}), }),
signal: options.abortSignal, signal: options.abortSignal,
@@ -44,11 +44,13 @@ async function* chatStreamMock(
userMessage: string, userMessage: string,
params: { params: {
thread_id: string; thread_id: string;
auto_accepted_plan: boolean;
max_plan_iterations: number; max_plan_iterations: number;
max_step_num: number; max_step_num: number;
interrupt_feedback?: string; interrupt_feedback?: string;
} = { } = {
thread_id: "__mock__", thread_id: "__mock__",
auto_accepted_plan: false,
max_plan_iterations: 3, max_plan_iterations: 3,
max_step_num: 1, max_step_num: 1,
interrupt_feedback: undefined, interrupt_feedback: undefined,

View File

@@ -9,6 +9,7 @@ const SETTINGS_KEY = "deerflow.settings";
const DEFAULT_SETTINGS: SettingsState = { const DEFAULT_SETTINGS: SettingsState = {
general: { general: {
autoAcceptedPlan: false,
maxPlanIterations: 1, maxPlanIterations: 1,
maxStepNum: 3, maxStepNum: 3,
}, },
@@ -44,6 +45,7 @@ const DEFAULT_SETTINGS: SettingsState = {
export type SettingsState = { export type SettingsState = {
general: { general: {
autoAcceptedPlan: boolean;
maxPlanIterations: number; maxPlanIterations: number;
maxStepNum: number; maxStepNum: number;
}; };

View File

@@ -107,6 +107,7 @@ export async function sendMessage(
content, content,
{ {
thread_id: THREAD_ID, thread_id: THREAD_ID,
auto_accepted_plan: generalSettings.autoAcceptedPlan,
max_plan_iterations: generalSettings.maxPlanIterations, max_plan_iterations: generalSettings.maxPlanIterations,
max_step_num: generalSettings.maxStepNum, max_step_num: generalSettings.maxStepNum,
interrupt_feedback: interruptFeedback, interrupt_feedback: interruptFeedback,