mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 12:20:34 +00:00
feat: add tool params node & tool params add array type (#2824)
* add tool params node * add tool params enum * node response * tool add array type params * fix tool params * fix * fix * fix
This commit is contained in:
@@ -60,12 +60,16 @@ export const runToolWithFunctionCall = async (
|
||||
type: string;
|
||||
description: string;
|
||||
required?: boolean;
|
||||
enum?: string[];
|
||||
}
|
||||
> = {};
|
||||
item.toolParams.forEach((item) => {
|
||||
const isArray = item.valueType?.startsWith('array');
|
||||
properties[item.key] = {
|
||||
type: item.valueType || 'string',
|
||||
description: item.toolDescription || ''
|
||||
type: isArray ? 'array' : item.valueType || 'string',
|
||||
...(isArray && { items: { type: item.valueType?.slice(5).toLowerCase() || 'string' } }),
|
||||
description: item.toolDescription || '',
|
||||
enum: item.enum?.split('\n').filter(Boolean) || []
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -68,12 +68,16 @@ export const runToolWithPromptCall = async (
|
||||
type: string;
|
||||
description: string;
|
||||
required?: boolean;
|
||||
enum?: string[];
|
||||
}
|
||||
> = {};
|
||||
item.toolParams.forEach((item) => {
|
||||
const isArray = item.valueType?.startsWith('array');
|
||||
properties[item.key] = {
|
||||
type: 'string',
|
||||
description: item.toolDescription || ''
|
||||
type: isArray ? 'array' : item.valueType || 'string',
|
||||
...(isArray && { items: { type: item.valueType?.slice(5).toLowerCase() || 'string' } }),
|
||||
description: item.toolDescription || '',
|
||||
enum: item.enum?.split('\n').filter(Boolean) || []
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -70,13 +70,20 @@ export const runToolWithToolChoice = async (
|
||||
{
|
||||
type: string;
|
||||
description: string;
|
||||
enum?: string[];
|
||||
required?: boolean;
|
||||
items?: {
|
||||
type: string;
|
||||
};
|
||||
}
|
||||
> = {};
|
||||
item.toolParams.forEach((item) => {
|
||||
const isArray = item.valueType?.startsWith('array');
|
||||
properties[item.key] = {
|
||||
type: item.valueType || 'string',
|
||||
description: item.toolDescription || ''
|
||||
type: isArray ? 'array' : item.valueType || 'string',
|
||||
...(isArray && { items: { type: item.valueType?.slice(5).toLowerCase() || 'string' } }),
|
||||
description: item.toolDescription || '',
|
||||
enum: item.enum?.split('\n').filter(Boolean) || []
|
||||
};
|
||||
});
|
||||
|
||||
@@ -138,7 +145,6 @@ export const runToolWithToolChoice = async (
|
||||
toolModel
|
||||
);
|
||||
|
||||
// console.log(JSON.stringify(requestBody, null, 2));
|
||||
/* Run llm */
|
||||
const ai = getAIApi({
|
||||
timeout: 480000
|
||||
|
@@ -0,0 +1,17 @@
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
|
||||
export type Props = ModuleDispatchProps<{}>;
|
||||
export type Response = DispatchNodeResultType<{}>;
|
||||
|
||||
export const dispatchToolParams = (props: Props): Response => {
|
||||
const { params } = props;
|
||||
|
||||
return {
|
||||
...params,
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
toolParamsResult: params
|
||||
}
|
||||
};
|
||||
};
|
@@ -70,6 +70,7 @@ import { dispatchLoop } from './loop/runLoop';
|
||||
import { dispatchLoopEnd } from './loop/runLoopEnd';
|
||||
import { dispatchLoopStart } from './loop/runLoopStart';
|
||||
import { dispatchFormInput } from './interactive/formInput';
|
||||
import { dispatchToolParams } from './agent/runTool/toolParams';
|
||||
|
||||
const callbackMap: Record<FlowNodeTypeEnum, Function> = {
|
||||
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
|
||||
@@ -87,6 +88,7 @@ const callbackMap: Record<FlowNodeTypeEnum, Function> = {
|
||||
[FlowNodeTypeEnum.queryExtension]: dispatchQueryExtension,
|
||||
[FlowNodeTypeEnum.tools]: dispatchRunTools,
|
||||
[FlowNodeTypeEnum.stopTool]: dispatchStopToolCall,
|
||||
[FlowNodeTypeEnum.toolParams]: dispatchToolParams,
|
||||
[FlowNodeTypeEnum.lafModule]: dispatchLafRequest,
|
||||
[FlowNodeTypeEnum.ifElseNode]: dispatchIfElse,
|
||||
[FlowNodeTypeEnum.variableUpdate]: dispatchUpdateVariable,
|
||||
|
Reference in New Issue
Block a user