chore: import upstream snapshot with attribution
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "node-http",
|
||||
"version": "1.4.10-next.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"example-start": "node dist/index.js",
|
||||
"example-dev": "nodemon ./src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@copilotkit/runtime": "workspace:*",
|
||||
"@copilotkit/shared": "workspace:*",
|
||||
"dotenv": "^16.4.7",
|
||||
"openai": "^4.85.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.11.17",
|
||||
"nodemon": "^3.1.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig": "workspace:*",
|
||||
"typescript": "^5.2.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { createServer } from "node:http";
|
||||
import {
|
||||
CopilotRuntime,
|
||||
OpenAIAdapter,
|
||||
copilotRuntimeNodeHttpEndpoint,
|
||||
} from "@copilotkit/runtime";
|
||||
import OpenAI from "openai";
|
||||
import * as dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const openai = new OpenAI();
|
||||
const serviceAdapter = new OpenAIAdapter({ openai: openai as any });
|
||||
|
||||
const runtime = new CopilotRuntime({
|
||||
actions: [
|
||||
{
|
||||
name: "sayHello",
|
||||
description: "say hello so someone by roasting their name",
|
||||
parameters: [
|
||||
{
|
||||
name: "roast",
|
||||
description: "A sentence or two roasting the name of the person",
|
||||
type: "string",
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
handler: ({ roast }) => {
|
||||
console.log(roast);
|
||||
return "The person has been roasted.";
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const copilotRuntime = copilotRuntimeNodeHttpEndpoint({
|
||||
endpoint: "/copilotkit",
|
||||
runtime,
|
||||
serviceAdapter,
|
||||
});
|
||||
|
||||
// const server = createServer(copilotRuntime);
|
||||
|
||||
// OR
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
return copilotRuntime(req, res);
|
||||
});
|
||||
|
||||
server.listen(4000, () => {
|
||||
console.log("Listening at http://localhost:4000/copilotkit");
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../../../packages/tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"strictNullChecks": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user