matt HOFFNER commited on
Commit
4c905d5
·
1 Parent(s): 86e6f59
src/app/search/web/page.jsx CHANGED
@@ -14,6 +14,9 @@ export default function WebSearchPage({ searchParams }) {
14
  useEffect(() => {
15
  const controller = new AbortController();
16
  const signal = controller.signal;
 
 
 
17
 
18
  async function fetchData() {
19
  const response = await fetch('/api/llm', {
@@ -44,7 +47,7 @@ export default function WebSearchPage({ searchParams }) {
44
  fetchData();
45
 
46
  return () => controller.abort();
47
- }, [searchParams, searchTerm]);
48
 
49
  console.log(aiResponse);
50
 
 
14
  useEffect(() => {
15
  const controller = new AbortController();
16
  const signal = controller.signal;
17
+ if (!searchTerm) {
18
+ return;
19
+ }
20
 
21
  async function fetchData() {
22
  const response = await fetch('/api/llm', {
 
47
  fetchData();
48
 
49
  return () => controller.abort();
50
+ }, [searchTerm]);
51
 
52
  console.log(aiResponse);
53
 
src/pages/api/stream.js CHANGED
@@ -80,17 +80,15 @@ export const LLMStream = async (
80
  controller.close();
81
  return;
82
  } else if (json.choices[0].finish_reason === "function_call") {
83
- console.log(json, 'function');
84
- /*
85
- const fnName = json.choices[0].message.function_call.name;
86
- const args = json.choices[0].message.function_call.arguments;
87
-
88
- const fn = functions[fnName];
89
- const result = await fn(...Object.values(JSON.parse(args)));
90
-
91
- console.log(`Function call: ${fnName}, Arguments: ${args}`);
92
- console.log(`Calling Function ${fnName} Result: ` + result);
93
- */
94
  }
95
  const text = json.choices[0].delta.content;
96
  const queue = encoder.encode(text);
 
80
  controller.close();
81
  return;
82
  } else if (json.choices[0].finish_reason === "function_call") {
83
+ console.log('function called', json);
84
+ const fnName = json.choices[0].message.function_call.name;
85
+ const args = json.choices[0].message.function_call.arguments;
86
+
87
+ const fn = functions[fnName];
88
+ const result = await fn(...Object.values(JSON.parse(args)));
89
+
90
+ console.log(`Function call: ${fnName}, Arguments: ${args}`);
91
+ console.log(`Calling Function ${fnName} Result: ` + result);
 
 
92
  }
93
  const text = json.choices[0].delta.content;
94
  const queue = encoder.encode(text);