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] 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 (
-