From 10adf2ba81bd4158e9a7f25cf7490eb59db9e6dc Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:52:01 +0000 Subject: [PATCH 01/12] add empties --- app/api/chat-with-functions/route.ts | 2 +- app/api/chat/route.ts | 2 +- app/components/navbar.tsx | 2 +- app/function-calling/page.tsx | 30 ++++++++++++++-------------- app/tri-display/layout.tsx | 2 +- app/tri-display/page.tsx | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/api/chat-with-functions/route.ts b/app/api/chat-with-functions/route.ts index e4227b3..9c54443 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..7bc0f8e 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.OPENAI_API || "", }); export const runtime = "edge"; diff --git a/app/components/navbar.tsx b/app/components/navbar.tsx index 425c78a..6b92ef9 100644 --- a/app/components/navbar.tsx +++ b/app/components/navbar.tsx @@ -3,7 +3,7 @@ import Link from "next/link"; export default function NavBar() { return (
- + Chat diff --git a/app/function-calling/page.tsx b/app/function-calling/page.tsx index 64d2ce0..199b44d 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 === "") { 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/layout.tsx b/app/tri-display/layout.tsx index e2d00d2..57d3d1e 100644 --- a/app/tri-display/layout.tsx +++ b/app/tri-display/layout.tsx @@ -9,7 +9,7 @@ export default function DualLayout(props: { docs: React.ReactNode; }) { return ( -
+
{props.data} {props.children} {props.docs} 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() { From 50672c400af5b67624204d66b73b750af20babec Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:54:58 +0000 Subject: [PATCH 02/12] remove prev caught empties --- app/api/chat-with-functions/route.ts | 2 +- app/api/chat/route.ts | 2 +- app/components/navbar.tsx | 2 +- app/function-calling/page.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/chat-with-functions/route.ts b/app/api/chat-with-functions/route.ts index 9c54443..e4227b3 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 7bc0f8e..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 || "", + apiKey: process.env.OP, }); export const runtime = "edge"; diff --git a/app/components/navbar.tsx b/app/components/navbar.tsx index 6b92ef9..425c78a 100644 --- a/app/components/navbar.tsx +++ b/app/components/navbar.tsx @@ -3,7 +3,7 @@ import Link from "next/link"; export default function NavBar() { return (
- + Chat diff --git a/app/function-calling/page.tsx b/app/function-calling/page.tsx index 199b44d..83ced4b 100644 --- a/app/function-calling/page.tsx +++ b/app/function-calling/page.tsx @@ -9,7 +9,7 @@ export default function Chat() { chatMessages, functionCall ) => { - if (functionCall.name === "") { + 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( From b9dcdf4cd3dd6d567670522cbb20c45f624e3957 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:02:07 +0000 Subject: [PATCH 03/12] remove to replace --- app/tri-display/layout.tsx | 2 +- app/tri-display/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tri-display/layout.tsx b/app/tri-display/layout.tsx index 57d3d1e..e2d00d2 100644 --- a/app/tri-display/layout.tsx +++ b/app/tri-display/layout.tsx @@ -9,7 +9,7 @@ export default function DualLayout(props: { docs: React.ReactNode; }) { return ( -
+
{props.data} {props.children} {props.docs} diff --git a/app/tri-display/page.tsx b/app/tri-display/page.tsx index b0a0095..f57b563 100644 --- a/app/tri-display/page.tsx +++ b/app/tri-display/page.tsx @@ -20,7 +20,7 @@ export default function Dual() { From 42963baaea22831f71069bfa81257b066284104a Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:03:04 +0000 Subject: [PATCH 04/12] add them back --- app/tri-display/layout.tsx | 2 +- app/tri-display/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tri-display/layout.tsx b/app/tri-display/layout.tsx index e2d00d2..57d3d1e 100644 --- a/app/tri-display/layout.tsx +++ b/app/tri-display/layout.tsx @@ -9,7 +9,7 @@ export default function DualLayout(props: { docs: React.ReactNode; }) { return ( -
+
{props.data} {props.children} {props.docs} 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() { From 5c891669b3739080191ca2aad3b90718a5ed8234 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:12:18 +0000 Subject: [PATCH 05/12] remove them --- app/tri-display/layout.tsx | 2 +- app/tri-display/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tri-display/layout.tsx b/app/tri-display/layout.tsx index 57d3d1e..e2d00d2 100644 --- a/app/tri-display/layout.tsx +++ b/app/tri-display/layout.tsx @@ -9,7 +9,7 @@ export default function DualLayout(props: { docs: React.ReactNode; }) { return ( -
+
{props.data} {props.children} {props.docs} diff --git a/app/tri-display/page.tsx b/app/tri-display/page.tsx index b0a0095..f57b563 100644 --- a/app/tri-display/page.tsx +++ b/app/tri-display/page.tsx @@ -20,7 +20,7 @@ export default function Dual() { From f52ec82cc66a2357303df3b999c42c47bb1c35e1 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:12:37 +0000 Subject: [PATCH 06/12] add them back --- app/tri-display/layout.tsx | 2 +- app/tri-display/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tri-display/layout.tsx b/app/tri-display/layout.tsx index e2d00d2..57d3d1e 100644 --- a/app/tri-display/layout.tsx +++ b/app/tri-display/layout.tsx @@ -9,7 +9,7 @@ export default function DualLayout(props: { docs: React.ReactNode; }) { return ( -
+
{props.data} {props.children} {props.docs} 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() { From 53da9117316bd954aa0dc45892407a1fcf850412 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:17:47 +0000 Subject: [PATCH 07/12] remvoe em --- app/tri-display/layout.tsx | 2 +- app/tri-display/page.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tri-display/layout.tsx b/app/tri-display/layout.tsx index 57d3d1e..e2d00d2 100644 --- a/app/tri-display/layout.tsx +++ b/app/tri-display/layout.tsx @@ -9,7 +9,7 @@ export default function DualLayout(props: { docs: React.ReactNode; }) { return ( -
+
{props.data} {props.children} {props.docs} diff --git a/app/tri-display/page.tsx b/app/tri-display/page.tsx index b0a0095..f57b563 100644 --- a/app/tri-display/page.tsx +++ b/app/tri-display/page.tsx @@ -20,7 +20,7 @@ export default function Dual() { From c5c81a44ae4bd937dcc6e5bc2e3baf93027fb085 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:18:19 +0000 Subject: [PATCH 08/12] add one back --- app/tri-display/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() { From 3b44b1bb39b18eb615ff0f03761c88ce8193a641 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:33:35 +0000 Subject: [PATCH 09/12] Update navbar.tsx --- app/components/navbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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
From 08af1fdcc10b24ba1dc8ec2f98d64bb9a5365d51 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:34:19 +0000 Subject: [PATCH 10/12] Update navbar.tsx --- app/components/navbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/navbar.tsx b/app/components/navbar.tsx index 962af77..3cc5c78 100644 --- a/app/components/navbar.tsx +++ b/app/components/navbar.tsx @@ -9,7 +9,7 @@ export default function NavBar() { Data - + Docs
From 2b1962ae13fb06358aca0aa4977043c1c7f0dd56 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:35:44 +0000 Subject: [PATCH 11/12] Update navbar.tsx --- app/components/navbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/navbar.tsx b/app/components/navbar.tsx index 3cc5c78..962af77 100644 --- a/app/components/navbar.tsx +++ b/app/components/navbar.tsx @@ -9,7 +9,7 @@ export default function NavBar() { Data - + Docs
From 17ed1804b68d50bcf464ca8f5366fe5585d8d0d5 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:37:39 +0000 Subject: [PATCH 12/12] Update route.ts --- app/api/chat-with-functions/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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";