59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
"use client";
|
|
import {
|
|
CopilotKit,
|
|
useCopilotAction,
|
|
useCopilotReadable,
|
|
} from "@copilotkit/react-core";
|
|
import { CopilotTextarea } from "@copilotkit/react-textarea";
|
|
import { CopilotSidebar } from "@copilotkit/react-ui";
|
|
import "@copilotkit/react-ui/styles.css";
|
|
import { useState } from "react";
|
|
import "@copilotkit/react-textarea/styles.css";
|
|
import "@copilotkit/react-ui/styles.css";
|
|
function InsideHome() {
|
|
const [message, setMessage] = useState("Hello World!");
|
|
const [text, setText] = useState("");
|
|
useCopilotReadable({
|
|
description: "This is the current message",
|
|
value: message,
|
|
});
|
|
useCopilotAction(
|
|
{
|
|
name: "displayMessage",
|
|
description: "Display a message.",
|
|
parameters: [
|
|
{
|
|
name: "message",
|
|
type: "string",
|
|
description: "The message to display.",
|
|
required: true,
|
|
},
|
|
],
|
|
handler: async ({ message }) => {
|
|
setMessage(message);
|
|
},
|
|
},
|
|
[],
|
|
);
|
|
return (
|
|
<>
|
|
<div>{message}</div>
|
|
</>
|
|
);
|
|
}
|
|
export default function Home() {
|
|
return (
|
|
<CopilotKit url="http://localhost:4000">
|
|
<CopilotSidebar
|
|
defaultOpen={true}
|
|
labels={{
|
|
title: "Presentation Copilot",
|
|
initial: "Hi you! 👋 I can give you a presentation on any topic.",
|
|
}}
|
|
>
|
|
<InsideHome />
|
|
</CopilotSidebar>
|
|
</CopilotKit>
|
|
);
|
|
}
|