Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add empties #43

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/chat-with-functions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion app/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function NavBar() {
<Link className="text-2xl font-bold" href="/docs">
Data
</Link>
<Link className="text-2xl font-bold" href="/data">
<Link className="text-2xl font-bold" href="">
Docs
</Link>
</div>
Expand Down
30 changes: 15 additions & 15 deletions app/function-calling/page.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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,
},
],
Expand All @@ -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<Message['role'], string> = {
system: 'red',
user: 'black',
function: 'blue',
assistant: 'green',
const roleToColorMap: Record<Message["role"], string> = {
system: "red",
user: "black",
function: "blue",
assistant: "green",
};

return (
Expand Down
2 changes: 1 addition & 1 deletion app/tri-display/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function Dual() {
<input
className="fixed bottom-0 w-full max-w-md p-2 mb-8 border border-gray-300 rounded shadow-xl"
value={input}
placeholder="Say something..."
placeholder=""
onChange={handleInputChange}
/>
</form>
Expand Down
Loading