nsarrazin HF Staff commited on
Commit
79b1d0e
·
unverified ·
1 Parent(s): 8e494b0

Ony call tools if model.tools is true (#1172)

Browse files

* Ony call tools if model.tools is true

* Add check to make sure we don't call tools on assistant

src/lib/server/textGeneration/index.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
  import { generate } from "./generate";
19
  import { mergeAsyncGenerators } from "$lib/utils/mergeAsyncGenerators";
20
  import type { TextGenerationContext } from "./types";
 
21
 
22
  export async function* textGeneration(ctx: TextGenerationContext) {
23
  yield* mergeAsyncGenerators([
@@ -56,8 +57,12 @@ async function* textGenerationWithoutTitle(
56
  if (messages[0].from === "system") messages[0].content = preprompt;
57
  }
58
 
59
- const tools = pickTools(toolsPreference, Boolean(assistant));
60
- const toolResults = yield* runTools(ctx, tools, preprompt);
 
 
 
 
61
 
62
  const processedMessages = await preprocessMessages(messages, webSearchResult, convId);
63
  yield* generate({ ...ctx, messages: processedMessages }, toolResults, preprompt);
 
18
  import { generate } from "./generate";
19
  import { mergeAsyncGenerators } from "$lib/utils/mergeAsyncGenerators";
20
  import type { TextGenerationContext } from "./types";
21
+ import type { ToolResult } from "$lib/types/Tool";
22
 
23
  export async function* textGeneration(ctx: TextGenerationContext) {
24
  yield* mergeAsyncGenerators([
 
57
  if (messages[0].from === "system") messages[0].content = preprompt;
58
  }
59
 
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
+ }
66
 
67
  const processedMessages = await preprocessMessages(messages, webSearchResult, convId);
68
  yield* generate({ ...ctx, messages: processedMessages }, toolResults, preprompt);