Skip to content

Commit cd1d8ed

Browse files
authored
Ony call tools if model.tools is true (#1172)
* Ony call tools if model.tools is true * Add check to make sure we don't call tools on assistant
1 parent 0078ac2 commit cd1d8ed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib/server/textGeneration/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { generate } from "./generate";
1919
import { mergeAsyncGenerators } from "$lib/utils/mergeAsyncGenerators";
2020
import type { TextGenerationContext } from "./types";
21+
import type { ToolResult } from "$lib/types/Tool";
2122

2223
export async function* textGeneration(ctx: TextGenerationContext) {
2324
yield* mergeAsyncGenerators([
@@ -56,8 +57,12 @@ async function* textGenerationWithoutTitle(
5657
if (messages[0].from === "system") messages[0].content = preprompt;
5758
}
5859

59-
const tools = pickTools(toolsPreference, Boolean(assistant));
60-
const toolResults = yield* runTools(ctx, tools, preprompt);
60+
let toolResults: ToolResult[] = [];
61+
62+
if (model.tools && !conv.assistantId) {
63+
const tools = pickTools(toolsPreference, Boolean(assistant));
64+
toolResults = yield* runTools(ctx, tools, preprompt);
65+
}
6166

6267
const processedMessages = await preprocessMessages(messages, webSearchResult, convId);
6368
yield* generate({ ...ctx, messages: processedMessages }, toolResults, preprompt);

0 commit comments

Comments
 (0)