diff --git a/app/api/chat-with-functions/route.ts b/app/api/chat-with-functions/route.ts index e4227b3..864b5af 100644 --- a/app/api/chat-with-functions/route.ts +++ b/app/api/chat-with-functions/route.ts @@ -3,7 +3,7 @@ import OpenAI from "openai"; import { OpenAIStream, StreamingTextResponse } from "ai"; const openai = new OpenAI({ - apiKey: process.env.OPENAI_API_KEY || , + apiKey: process.env.OPENAI_API_KEY || "", }); export const runtime = "node"; diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 3eeba50..6084c47 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -3,7 +3,7 @@ import OpenAI from "openai"; import { OpenAIStream, StreamingTextResponse } from "ai"; const openai = new OpenAI({ - apiKey: process.env.OPENAI_API_KEY || "", + apiKey: process.env.OP, }); export const runtime = "edge"; diff --git a/app/components/navbar.tsx b/app/components/navbar.tsx index 425c78a..962af77 100644 --- a/app/components/navbar.tsx +++ b/app/components/navbar.tsx @@ -9,7 +9,7 @@ export default function NavBar() { Data - + Docs diff --git a/app/function-calling/page.tsx b/app/function-calling/page.tsx index 64d2ce0..83ced4b 100644 --- a/app/function-calling/page.tsx +++ b/app/function-calling/page.tsx @@ -1,19 +1,19 @@ -'use client'; +"use client"; -import { Message } from 'ai/react'; -import { useChat } from 'ai/react'; -import { ChatRequest, FunctionCallHandler, nanoid } from 'ai'; +import { Message } from "ai/react"; +import { useChat } from "ai/react"; +import { ChatRequest, FunctionCallHandler, nanoid } from "ai"; export default function Chat() { const functionCallHandler: FunctionCallHandler = async ( chatMessages, - functionCall, + functionCall ) => { - if (functionCall.name === 'eval_code_in_browser') { + if (functionCall.name === "eval_code_in_browser") { if (functionCall.arguments) { // Parsing here does not always work since it seems that some characters in generated code aren't escaped properly. const parsedFunctionCallArguments: { code: string } = JSON.parse( - functionCall.arguments, + functionCall.arguments ); // WARNING: Do NOT do this in real-world applications! eval(parsedFunctionCallArguments.code); @@ -22,8 +22,8 @@ export default function Chat() { ...chatMessages, { id: nanoid(), - name: 'eval_code_in_browser', - role: 'function' as const, + name: "eval_code_in_browser", + role: "function" as const, content: parsedFunctionCallArguments.code, }, ], @@ -34,16 +34,16 @@ export default function Chat() { }; const { messages, input, handleInputChange, handleSubmit, data } = useChat({ - api: '/api/chat-with-functions', + api: "/api/chat-with-functions", experimental_onFunctionCall: functionCallHandler, }); // Generate a map of message role to text color - const roleToColorMap: Record = { - system: 'red', - user: 'black', - function: 'blue', - assistant: 'green', + const roleToColorMap: Record = { + system: "red", + user: "black", + function: "blue", + assistant: "green", }; return ( diff --git a/app/tri-display/page.tsx b/app/tri-display/page.tsx index f57b563..b0a0095 100644 --- a/app/tri-display/page.tsx +++ b/app/tri-display/page.tsx @@ -20,7 +20,7 @@ export default function Dual() {