nsarrazin HF Staff commited on
Commit
4003083
·
unverified ·
1 Parent(s): 612576b

fix websearch on assistants (#1244)

Browse files
src/lib/server/textGeneration/index.ts CHANGED
@@ -41,14 +41,15 @@ async function* textGenerationWithoutTitle(
41
  const { model, conv, messages, assistant, isContinue, webSearch, toolsPreference } = ctx;
42
  const convId = conv._id;
43
 
44
- // perform websearch if requested
45
- // it can be because the user toggled the webSearch or because the assistant has webSearch enabled
46
- // if tools are enabled, we don't perform it here since we will add the websearch as a tool
47
  let webSearchResult: WebSearch | undefined;
 
 
 
 
 
48
  if (
49
  !isContinue &&
50
- !model.tools &&
51
- ((webSearch && !conv.assistantId) || assistantHasWebSearch(assistant))
52
  ) {
53
  webSearchResult = yield* runWebSearch(conv, messages, assistant?.rag);
54
  }
 
41
  const { model, conv, messages, assistant, isContinue, webSearch, toolsPreference } = ctx;
42
  const convId = conv._id;
43
 
 
 
 
44
  let webSearchResult: WebSearch | undefined;
45
+
46
+ // run websearch if:
47
+ // - it's not continuing a previous message
48
+ // - AND the model doesn't support tools and websearch is selected
49
+ // - OR the assistant has websearch enabled (no tools for assistants for now)
50
  if (
51
  !isContinue &&
52
+ ((!model.tools && webSearch && !conv.assistantId) || assistantHasWebSearch(assistant))
 
53
  ) {
54
  webSearchResult = yield* runWebSearch(conv, messages, assistant?.rag);
55
  }