nsarrazin HF Staff commited on
Commit
29ea0af
·
unverified ·
1 Parent(s): 42493bc

fix(assistants): only enable websearch on assistants with RAG (#1452)

Browse files
src/lib/server/textGeneration/tools.ts CHANGED
@@ -21,18 +21,21 @@ import { collections } from "../database";
21
  import { ObjectId } from "mongodb";
22
  import type { Message } from "$lib/types/Message";
23
  import type { Assistant } from "$lib/types/Assistant";
 
24
 
25
  export async function getTools(
26
  toolsPreference: Array<string>,
27
- assistant: Pick<Assistant, "tools"> | undefined
28
  ): Promise<Tool[]> {
29
  let preferences = toolsPreference;
30
 
31
  if (assistant) {
32
  if (assistant?.tools?.length) {
33
  preferences = assistant.tools;
34
- } else {
35
  return [directlyAnswer, websearch];
 
 
36
  }
37
  }
38
 
 
21
  import { ObjectId } from "mongodb";
22
  import type { Message } from "$lib/types/Message";
23
  import type { Assistant } from "$lib/types/Assistant";
24
+ import { assistantHasWebSearch } from "./assistant";
25
 
26
  export async function getTools(
27
  toolsPreference: Array<string>,
28
+ assistant: Pick<Assistant, "rag" | "tools"> | undefined
29
  ): Promise<Tool[]> {
30
  let preferences = toolsPreference;
31
 
32
  if (assistant) {
33
  if (assistant?.tools?.length) {
34
  preferences = assistant.tools;
35
+ } else if (assistantHasWebSearch(assistant)) {
36
  return [directlyAnswer, websearch];
37
+ } else {
38
+ return [directlyAnswer];
39
  }
40
  }
41