Spaces:
Sleeping
Sleeping
matt HOFFNER
commited on
Commit
·
5f5314e
1
Parent(s):
a98334b
cleanup
Browse files- app/page.tsx +0 -8
- pages/api/functions/index.ts +4 -4
app/page.tsx
CHANGED
@@ -49,14 +49,6 @@ const Page: React.FC = () => {
|
|
49 |
};
|
50 |
const { messages, input, setInput, handleSubmit, isLoading } = useChat({
|
51 |
experimental_onFunctionCall: functionCallHandler,
|
52 |
-
onResponse: (response: { status: number; }) => {
|
53 |
-
if (response.status === 410) {
|
54 |
-
toast.error("You have reached your request limit for the day.");
|
55 |
-
return;
|
56 |
-
} else {
|
57 |
-
console.log("chat initialized");
|
58 |
-
}
|
59 |
-
},
|
60 |
onError: (error: any) => {
|
61 |
console.log(error);
|
62 |
},
|
|
|
49 |
};
|
50 |
const { messages, input, setInput, handleSubmit, isLoading } = useChat({
|
51 |
experimental_onFunctionCall: functionCallHandler,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
onError: (error: any) => {
|
53 |
console.log(error);
|
54 |
},
|
pages/api/functions/index.ts
CHANGED
@@ -91,7 +91,7 @@ const surferEmbedApi = async ({ input }: any) => {
|
|
91 |
}
|
92 |
|
93 |
const serpEmbedApi = async ({ input }: any) => {
|
94 |
-
const content: string = await serpApi({
|
95 |
const documents = await textSplitter.createDocuments([content]);
|
96 |
const vectorStore = await MemoryVectorStore.fromTexts(
|
97 |
// @ts-ignore
|
@@ -109,11 +109,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|
109 |
const functionName = req.body.name as string;
|
110 |
|
111 |
try {
|
112 |
-
if (functionName === '
|
113 |
-
const result = await serpEmbedApi(
|
114 |
return res.status(200).send(result);
|
115 |
} else {
|
116 |
-
const result = await surferEmbedApi(
|
117 |
return res.status(200).send(result);
|
118 |
}
|
119 |
} catch (error) {
|
|
|
91 |
}
|
92 |
|
93 |
const serpEmbedApi = async ({ input }: any) => {
|
94 |
+
const content: string = await serpApi({input})
|
95 |
const documents = await textSplitter.createDocuments([content]);
|
96 |
const vectorStore = await MemoryVectorStore.fromTexts(
|
97 |
// @ts-ignore
|
|
|
109 |
const functionName = req.body.name as string;
|
110 |
|
111 |
try {
|
112 |
+
if (functionName === 'searchApi') {
|
113 |
+
const result = await serpEmbedApi(JSON.parse(prompt));
|
114 |
return res.status(200).send(result);
|
115 |
} else {
|
116 |
+
const result = await surferEmbedApi(prompt)
|
117 |
return res.status(200).send(result);
|
118 |
}
|
119 |
} catch (error) {
|