feat: config max_search_results for search engine (#192)

* feat: implement UI

* feat: config max_search_results for search engine via api

---------

Co-authored-by: Henry Li <henry1943@163.com>
This commit is contained in:
DanielWalnut
2025-05-17 22:23:52 -07:00
committed by GitHub
parent c6bbc595c3
commit 8bbcdbe4de
14 changed files with 101 additions and 85 deletions

View File

@@ -32,6 +32,9 @@ const generalFormSchema = z.object({
maxStepNum: z.number().min(1, {
message: "Max step number must be at least 1.",
}),
maxSearchResults: z.number().min(1, {
message: "Max search results must be at least 1.",
}),
});
export const GeneralTab: Tab = ({
@@ -143,6 +146,30 @@ export const GeneralTab: Tab = ({
</FormItem>
)}
/>
<FormField
control={form.control}
name="maxSearchResults"
render={({ field }) => (
<FormItem>
<FormLabel>Max search results</FormLabel>
<FormControl>
<Input
className="w-60"
type="number"
defaultValue={field.value}
min={1}
onChange={(event) =>
field.onChange(parseInt(event.target.value || "0"))
}
/>
</FormControl>
<FormDescription>
By default, each search step has 3 results.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</form>
</Form>
</main>

View File

@@ -18,6 +18,7 @@ export async function* chatStream(
auto_accepted_plan: boolean;
max_plan_iterations: number;
max_step_num: number;
max_search_results?: number;
interrupt_feedback?: string;
enable_background_investigation: boolean;
mcp_settings?: {
@@ -61,12 +62,14 @@ async function* chatReplayStream(
auto_accepted_plan: boolean;
max_plan_iterations: number;
max_step_num: number;
max_search_results?: number;
interrupt_feedback?: string;
} = {
thread_id: "__mock__",
auto_accepted_plan: false,
max_plan_iterations: 3,
max_step_num: 1,
max_search_results: 3,
interrupt_feedback: undefined,
},
options: { abortSignal?: AbortSignal } = {},
@@ -157,6 +160,7 @@ export async function fetchReplayTitle() {
auto_accepted_plan: false,
max_plan_iterations: 3,
max_step_num: 1,
max_search_results: 3,
},
{},
);

View File

@@ -13,6 +13,7 @@ const DEFAULT_SETTINGS: SettingsState = {
enableBackgroundInvestigation: false,
maxPlanIterations: 1,
maxStepNum: 3,
maxSearchResults: 3,
},
mcp: {
servers: [],
@@ -25,6 +26,7 @@ export type SettingsState = {
enableBackgroundInvestigation: boolean;
maxPlanIterations: number;
maxStepNum: number;
maxSearchResults: number;
};
mcp: {
servers: MCPServerMetadata[];

View File

@@ -104,6 +104,7 @@ export async function sendMessage(
settings.enableBackgroundInvestigation ?? true,
max_plan_iterations: settings.maxPlanIterations,
max_step_num: settings.maxStepNum,
max_search_results: settings.maxSearchResults,
mcp_settings: settings.mcpSettings,
},
options,