Skip to content

Commit

Permalink
add empties
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Mar 25, 2024
1 parent 7476720 commit 10adf2b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
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 || "" ,
});

This comment has been minimized.

Copy link
@github-actions

github-actions bot Mar 25, 2024

Empty string detected!


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.OPENAI_API || "",
});

This comment has been minimized.

Copy link
@github-actions

github-actions bot Mar 25, 2024

Empty string detected!


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 @@ -3,7 +3,7 @@ import Link from "next/link";
export default function NavBar() {
return (
<div className="flex items-center p-4 justify-center text-center gap-14 ">
<Link className="text-2xl font-bold" href="/">
<Link className="text-2xl font-bold" href="">
Chat

This comment has been minimized.

Copy link
@github-actions

github-actions bot Mar 25, 2024

Empty string detected!

</Link>
<Link className="text-2xl font-bold" href="/docs">
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 (

This comment has been minimized.

Copy link
@github-actions

github-actions bot Mar 25, 2024

Empty string detected!

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);
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/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function DualLayout(props: {
docs: React.ReactNode;
}) {
return (
<div className="grid grid-cols-3 shrink">
<div className="">
{props.data}
{props.children}
{props.docs}
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

0 comments on commit 10adf2b

Please sign in to comment.