Skip to content

Commit

Permalink
feat: max call tool times
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Sep 7, 2024
1 parent e90194d commit 2eecded
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
...props,
toolNodes,
toolModel,
maxRunToolTimes: 30,
messages: adaptMessages
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,25 @@ export const runToolWithToolChoice = async (
messages: ChatCompletionMessageParam[];
toolNodes: ToolNodeItemType[];
toolModel: LLMModelItemType;
maxRunToolTimes: number;
},
response?: RunToolResponse
): Promise<RunToolResponse> => {
const { messages, toolNodes, toolModel, maxRunToolTimes, ...workflowProps } = props;
const {
toolModel,
toolNodes,
messages,
res,
requestOrigin,
runtimeNodes,
node,
stream,
workflowStreamResponse,
params: { temperature = 0, maxToken = 4000, aiChatVision }
} = props;
} = workflowProps;

if (maxRunToolTimes <= 0 && response) {
return response;
}

const assistantResponses = response?.assistantResponses || [];

const tools: ChatCompletionTool[] = toolNodes.map((item) => {
Expand Down Expand Up @@ -196,7 +200,7 @@ export const runToolWithToolChoice = async (
})();

const toolRunResponse = await dispatchWorkFlow({
...props,
...workflowProps,
isToolCall: true,
runtimeNodes: runtimeNodes.map((item) =>
item.nodeId === toolNode.nodeId
Expand Down Expand Up @@ -325,6 +329,7 @@ export const runToolWithToolChoice = async (
return runToolWithToolChoice(
{
...props,
maxRunToolTimes: maxRunToolTimes - 1,
messages: completeMessages
},
{
Expand Down

0 comments on commit 2eecded

Please sign in to comment.