Feat: Add retrieval tool #3221 (#8491)

### What problem does this PR solve?

Feat: Add retrieval tool #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-25 18:32:56 +08:00
committed by GitHub
parent 7353070f49
commit c4bfd9fa2c
23 changed files with 2340 additions and 2235 deletions

View File

@ -10,7 +10,6 @@ import {
FormItem,
FormLabel,
} from '@/components/ui/form';
import { Textarea } from '@/components/ui/textarea';
import { zodResolver } from '@hookform/resolvers/zod';
import { Position } from '@xyflow/react';
import { useContext, useMemo } from 'react';
@ -22,6 +21,7 @@ import { AgentInstanceContext } from '../../context';
import { INextOperatorForm } from '../../interface';
import useGraphStore from '../../store';
import { isBottomSubAgent } from '../../utils';
import { DescriptionField } from '../components/description-field';
import { Output } from '../components/output';
import { PromptEditor } from '../components/prompt-editor';
import { AgentTools } from './agent-tools';
@ -85,20 +85,7 @@ const AgentForm = ({ node }: INextOperatorForm) => {
}}
>
<FormContainer>
{isSubAgent && (
<FormField
control={form.control}
name={`description`}
render={({ field }) => (
<FormItem className="flex-1">
<FormLabel>Description</FormLabel>
<FormControl>
<Textarea {...field}></Textarea>
</FormControl>
</FormItem>
)}
/>
)}
{isSubAgent && <DescriptionField></DescriptionField>}
<LargeModelFormField></LargeModelFormField>
<FormField
control={form.control}

View File

@ -42,6 +42,7 @@ const Menus = [
Operator.Invoke,
Operator.Crawler,
Operator.Code,
Operator.Retrieval,
],
},
];

View File

@ -1,4 +1,5 @@
import { IAgentForm } from '@/interfaces/database/agent';
import { DefaultAgentToolValuesMap } from '@/pages/agent/constant';
import { AgentFormContext } from '@/pages/agent/context';
import useGraphStore from '@/pages/agent/store';
import { get } from 'lodash';
@ -23,7 +24,17 @@ export function useUpdateAgentNodeTools() {
if (node?.id) {
const nextValue = value.reduce<IAgentForm['tools']>((pre, cur) => {
const tool = tools.find((x) => x.component_name === cur);
pre.push(tool ? tool : { component_name: cur, params: {} });
pre.push(
tool
? tool
: {
component_name: cur,
params:
DefaultAgentToolValuesMap[
cur as keyof typeof DefaultAgentToolValuesMap
] || {},
},
);
return pre;
}, []);