chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @filePath server.ts
|
||||
*/
|
||||
import express from "express";
|
||||
import {
|
||||
CopilotRuntime,
|
||||
OpenAIAdapter,
|
||||
copilotRuntimeNodeHttpEndpoint,
|
||||
} from "@copilotkit/runtime";
|
||||
import OpenAI from "openai";
|
||||
|
||||
const openai = new OpenAI();
|
||||
const serviceAdapter = new OpenAIAdapter({ openai });
|
||||
|
||||
const runtime = new CopilotRuntime();
|
||||
|
||||
const copilotRuntime = copilotRuntimeNodeHttpEndpoint({
|
||||
endpoint: "/copilotkit",
|
||||
runtime,
|
||||
serviceAdapter,
|
||||
});
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use("/copilotkit", copilotRuntime);
|
||||
|
||||
app.listen(4000, () => {
|
||||
console.log("Listening at http://localhost:4000/copilotkit");
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
"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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @filePath server.ts
|
||||
*/
|
||||
import { createServer } from "node:http";
|
||||
import {
|
||||
CopilotRuntime,
|
||||
OpenAIAdapter,
|
||||
copilotRuntimeNodeHttpEndpoint,
|
||||
} from "@copilotkit/runtime";
|
||||
import OpenAI from "openai";
|
||||
|
||||
const openai = new OpenAI();
|
||||
const serviceAdapter = new OpenAIAdapter({ openai });
|
||||
|
||||
const runtime = new CopilotRuntime();
|
||||
|
||||
const copilotRuntime = copilotRuntimeNodeHttpEndpoint({
|
||||
endpoint: "/copilotkit",
|
||||
runtime,
|
||||
serviceAdapter,
|
||||
});
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
return copilotRuntime(req, res);
|
||||
});
|
||||
|
||||
server.listen(4000, () => {
|
||||
console.log("Listening at http://localhost:4000/copilotkit");
|
||||
});
|
||||
Reference in New Issue
Block a user