nsarrazin HF staff victor HF staff commited on
Commit
b3c073e
1 Parent(s): 5eb8f00

Disable websearch on assistants, server & client side (#778)

Browse files

* Disable websearch on assistants, server & client side

* Update src/routes/conversation/[id]/+page.svelte

Co-authored-by: Victor Muštar <victor.mustar@gmail.com>

* missing comma

---------

Co-authored-by: Victor Muštar <victor.mustar@gmail.com>

src/routes/conversation/[id]/+page.svelte CHANGED
@@ -143,6 +143,9 @@
143
 
144
  files = [];
145
 
 
 
 
146
  const response = await fetch(`${base}/conversation/${$page.params.id}`, {
147
  method: "POST",
148
  headers: { "Content-Type": "application/json" },
@@ -151,7 +154,7 @@
151
  id: messageId,
152
  is_retry: isRetry,
153
  is_continue: isContinue,
154
- web_search: $webSearchParameters.useSearch,
155
  files: isRetry ? undefined : resizedImages,
156
  }),
157
  });
 
143
 
144
  files = [];
145
 
146
+ // disable websearch if assistant is present
147
+ const hasAssistant = !!$page.data.assistant;
148
+
149
  const response = await fetch(`${base}/conversation/${$page.params.id}`, {
150
  method: "POST",
151
  headers: { "Content-Type": "application/json" },
 
154
  id: messageId,
155
  is_retry: isRetry,
156
  is_continue: isContinue,
157
+ web_search: !hasAssistant && $webSearchParameters.useSearch,
158
  files: isRetry ? undefined : resizedImages,
159
  }),
160
  });
src/routes/conversation/[id]/+server.ts CHANGED
@@ -250,7 +250,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
250
 
251
  let webSearchResults: WebSearch | undefined;
252
 
253
- if (webSearch && !isContinue) {
254
  webSearchResults = await runWebSearch(conv, messages[messages.length - 1].content, update);
255
  messages[messages.length - 1].webSearch = webSearchResults;
256
  } else if (isContinue) {
 
250
 
251
  let webSearchResults: WebSearch | undefined;
252
 
253
+ if (webSearch && !isContinue && !conv.assistantId) {
254
  webSearchResults = await runWebSearch(conv, messages[messages.length - 1].content, update);
255
  messages[messages.length - 1].webSearch = webSearchResults;
256
  } else if (isContinue) {