chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:58:18 +08:00
commit 6d5d58c1a9
18293 changed files with 3502153 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
ACTIONS_APP_PATH="/tmp/test-actions-app"
echo "Creating next app in $ACTIONS_APP_PATH"
echo ""
# Remove prev project and run create-next-app
npx create-next-app $ACTIONS_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
npm_install_packages $ACTIONS_APP_PATH
cp -r scripts/qa/lib/actions $ACTIONS_APP_PATH/src/app/actions
# Open VSCode
code $ACTIONS_APP_PATH
prompt "Are all actions in the 'good' folder without errors in VSCode?"
prompt "Do all actions in the 'bad' folder have errors in VSCode?"
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0
+62
View File
@@ -0,0 +1,62 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
CSS_APP_PATH="/tmp/test-css-app"
echo "Creating next app in $CSS_APP_PATH"
echo ""
# Remove prev project and run create-next-app
rm -rf $CSS_APP_PATH
npx create-next-app $CSS_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $CSS_APP_PATH/.env
npm_install_packages $CSS_APP_PATH
cp scripts/qa/lib/css/page.tsx $CSS_APP_PATH/src/app/page.tsx
# Open VSCode
code $CSS_APP_PATH
mkdir -p $CSS_APP_PATH/src/app/api/copilotkit/openai/
cp scripts/qa/lib/css/route.ts $CSS_APP_PATH/src/app/api/copilotkit/openai/route.ts
# Temporarily disable -e
set +e
pushd $CSS_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
npm run dev > /dev/null 2>&1 &
pid1=$!
popd
prompt "Open http://localhost:3000. Does it load with custom colors and icons?"
killall next-server;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0
+74
View File
@@ -0,0 +1,74 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
FIREBASE_APP_PATH="/tmp/test-firebase-app"
rm -rf $FIREBASE_APP_PATH
echo "Creating firebase app in $FIREBASE_APP_PATH"
# prepare the python app
mkdir -p $FIREBASE_APP_PATH
npx create-next-app $FIREBASE_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $FIREBASE_APP_PATH/.env
npm_install_packages $FIREBASE_APP_PATH
mkdir -p $FIREBASE_APP_PATH/functions
mkdir -p $FIREBASE_APP_PATH/functions/src
cp scripts/qa/lib/firebase/.firebaserc $FIREBASE_APP_PATH/.firebaserc
cp scripts/qa/lib/firebase/firebase.json $FIREBASE_APP_PATH/firebase.json
cp scripts/qa/lib/firebase/index.ts $FIREBASE_APP_PATH/functions/src/index.ts
cp scripts/qa/lib/firebase/package.json $FIREBASE_APP_PATH/functions/package.json
cp scripts/qa/lib/firebase/tsconfig.json $FIREBASE_APP_PATH/functions/tsconfig.json
cp scripts/qa/lib/firebase/page.tsx $FIREBASE_APP_PATH/src/app/page.tsx
npm_install_packages $FIREBASE_APP_PATH/functions
# Temporarily disable -e
set +e
pushd $FIREBASE_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
# Start next server
npm run dev > /dev/null 2>&1 &
pid1=$!
popd
# Start firebase
pushd $FIREBASE_APP_PATH/functions
npm run serve > /dev/null 2>&1 &
pid2=$!
popd
prompt "Open http://localhost:3000. Is the page without errors?"
prompt "Chat with it. Does it work?"
prompt "Ask it to change the message. Does it work?"
killall next-server;
cleanup;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0;
+72
View File
@@ -0,0 +1,72 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
LC_APP_PATH="/tmp/test-langchain-app"
echo "Creating next app in $LC_APP_PATH"
echo ""
# Remove prev project and run create-next-app
rm -rf $LC_APP_PATH
npx create-next-app $LC_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $LC_APP_PATH/.env
npm_install_packages $LC_APP_PATH
(cd $LC_APP_PATH && npm install @langchain/community@latest @langchain/core@latest @langchain/langgraph@latest @langchain/openai@latest)
cp scripts/qa/lib/langchain/page.tsx $LC_APP_PATH/src/app/page.tsx
# Open VSCode
code $LC_APP_PATH
mkdir -p $LC_APP_PATH/src/app/api/copilotkit/langchain/
cp scripts/qa/lib/langchain/route.ts $LC_APP_PATH/src/app/api/copilotkit/langchain/route.ts
prompt "Open route.ts. Is it without errors in VSCode?"
# Temporarily disable -e
set +e
pushd $LC_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
npm run dev > /dev/null 2>&1 &
pid1=$!
popd
prompt "Open http://localhost:3000. Is the page without errors?"
prompt "Chat to check if regular text and message history works (2x)?"
prompt "Ask the copilot to change the message. Is the message changed?"
prompt "Ask the copilot to change the message again. Is the message changed?"
prompt "Ask for a long message. Does the custom render work & stream?"
prompt "Does it provide the current message when asked?"
prompt "Test the keyboard shortcut cmd-\\ to open close the sidebar. Does it work?"
prompt "Does the text input autofocus when the sidebar is opened?"
prompt "In the text area, start a text about elephants. Does the autosuggestions work?"
killall next-server;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0
+90
View File
@@ -0,0 +1,90 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
LANGSERVE_APP_PATH="/tmp/test-langserve-app"
LANGSERVE_PYTHON_APP_PATH="/tmp/test-langserve-app-python"
rm -rf $LANGSERVE_APP_PATH
rm -rf $LANGSERVE_PYTHON_APP_PATH
echo "Creating langserve app in $LANGSERVE_APP_PATH and $LANGSERVE_PYTHON_APP_PATH"
# prepare the python app
mkdir -p $LANGSERVE_PYTHON_APP_PATH
mkdir -p $LANGSERVE_PYTHON_APP_PATH/app
cp "scripts/qa/lib/langserve/requirements.txt" $LANGSERVE_PYTHON_APP_PATH
cp "scripts/qa/lib/langserve/app/server.py" $LANGSERVE_PYTHON_APP_PATH/app
pushd $LANGSERVE_PYTHON_APP_PATH
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $LANGSERVE_PYTHON_APP_PATH/.env
popd
mkdir -p $LANGSERVE_APP_PATH
npx create-next-app $LANGSERVE_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $LANGSERVE_APP_PATH/.env
npm_install_packages $LANGSERVE_APP_PATH
(cd $LANGSERVE_APP_PATH && npm install @langchain/community @langchain/core @langchain/langgraph @langchain/openai langchain openai --save)
cp scripts/qa/lib/langserve/next/page.tsx $LANGSERVE_APP_PATH/src/app/page.tsx
mkdir -p $LANGSERVE_APP_PATH/src/app/api/copilotkit/openai/
cp scripts/qa/lib/langserve/next/route.ts $LANGSERVE_APP_PATH/src/app/api/copilotkit/openai/route.ts
# Open VSCode
code $LANGSERVE_APP_PATH
prompt "Open route.ts. Is it without errors in VSCode?"
# Temporarily disable -e
set +e
pushd $LANGSERVE_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
# Start next server
npm run dev > /dev/null 2>&1 &
next_pid=$!
popd
# Start python server
pushd $LANGSERVE_PYTHON_APP_PATH
python app/server.py > /dev/null 2>&1 &
python_pid=$!
popd
prompt "Open http://localhost:3000. Is the page without errors?"
prompt "Ask it to say hello to a name. Does it say hello in a ridiculous way?"
prompt "Ask it what dogs like to check langserve. Does it say sticks?"
prompt "Ask it what Eugene thinks about cats. Does it say cats like fish?"
killall next-server;
cleanup;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0;
+29
View File
@@ -0,0 +1,29 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "object",
parameters: [
{
name: "arg",
type: "object[]",
description: "The object argument to display.",
attributes: [
{
name: "x",
type: "string",
description: "The x attribute.",
},
{
name: "y",
type: "number",
description: "The y attribute.",
},
],
},
],
handler: async ({ arg }) => {
const x: string = arg[0].x;
const y: number = arg[0].y;
const z: boolean = arg[0].z;
},
});
+26
View File
@@ -0,0 +1,26 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "enum",
parameters: [
{
name: "arg",
type: "string",
description: "The enum to display.",
enum: ["one", "two", "three"],
},
],
handler: async ({ arg }) => {
switch (arg) {
case "one":
console.log("One");
break;
case "two":
console.log("Two");
break;
default:
const exhaustiveCheck: never = arg;
}
console.log("No args action");
},
});
+8
View File
@@ -0,0 +1,8 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "noargs",
handler: async (args) => {
console.log("No args action");
},
});
+29
View File
@@ -0,0 +1,29 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "object",
parameters: [
{
name: "arg",
type: "object",
description: "The object argument to display.",
attributes: [
{
name: "x",
type: "string",
description: "The x attribute.",
},
{
name: "y",
type: "number",
description: "The y attribute.",
},
],
},
],
handler: async ({ arg }) => {
const x: string = arg.x;
const y: number = arg.y;
const z: boolean = arg.z;
},
});
+17
View File
@@ -0,0 +1,17 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "optional",
parameters: [
{
name: "arg",
type: "string",
description: "The optional argument to display.",
required: false,
},
],
handler: async ({ arg }) => {
// TODO this should fail
let x: string = arg;
},
});
+28
View File
@@ -0,0 +1,28 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "array",
parameters: [
{
name: "arg",
type: "object[]",
description: "The object argument to display.",
attributes: [
{
name: "x",
type: "string",
description: "The x attribute.",
},
{
name: "y",
type: "number",
description: "The y attribute.",
},
],
},
],
handler: async ({ arg }) => {
const x: string = arg[0].x;
const y: number = arg[0].y;
},
});
+29
View File
@@ -0,0 +1,29 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "enum",
parameters: [
{
name: "arg",
type: "string",
description: "The enum to display.",
enum: ["one", "two", "three"],
},
],
handler: async ({ arg }) => {
switch (arg) {
case "one":
console.log("One");
break;
case "two":
console.log("Two");
break;
case "three":
console.log("Three");
break;
default:
const exhaustiveCheck: never = arg;
}
console.log("No args action");
},
});
+8
View File
@@ -0,0 +1,8 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "noargs",
handler: async () => {
console.log("No args action");
},
});
+28
View File
@@ -0,0 +1,28 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "object",
parameters: [
{
name: "arg",
type: "object",
description: "The object argument to display.",
attributes: [
{
name: "x",
type: "string",
description: "The x attribute.",
},
{
name: "y",
type: "number",
description: "The y attribute.",
},
],
},
],
handler: async ({ arg }) => {
const x: string = arg.x;
const y: number = arg.y;
},
});
+20
View File
@@ -0,0 +1,20 @@
import { useCopilotAction } from "@copilotkit/react-core";
useCopilotAction({
name: "optional",
parameters: [
{
name: "arg",
type: "string",
description: "The optional argument to display.",
required: false,
},
],
handler: async ({ arg }) => {
let x: string = "y";
if (arg !== undefined) {
x = arg;
}
},
});
+95
View File
@@ -0,0 +1,95 @@
#!/bin/bash
get_latest_versions() {
local result="" # Initialize an empty string to hold the results
for pkg in "$@"; do
# Encode the package name for use in a URL
encoded_pkg=$(echo "$pkg" | sed 's|/|%2F|g')
# Fetch the latest version of the package
latest_version=$(curl -s "https://registry.npmjs.org/$encoded_pkg" | jq -r '.["dist-tags"].latest')
# Check if the latest version was found
if [[ $latest_version != "null" && ! -z $latest_version ]]; then
# Append the package and version to the result string, separated by '@' and spaces between packages
result+="${pkg}@${latest_version} "
else
echo "Latest version for package ${pkg} could not be found." >&2
return 1 # Optionally return an error code if a package's latest version can't be found
fi
done
# Trim the trailing space and print the result
echo "${result% }"
}
get_latest_copilotkit_versions() {
get_latest_versions "@copilotkit/backend" "@copilotkit/react-core" "@copilotkit/react-textarea" "@copilotkit/react-ui" "@copilotkit/shared"
}
get_latest_prerelease_versions() {
local result="" # Initialize an empty string to hold the results
local tag_part="$1" # The specific part of the tag to match
# Shift the arguments so $@ contains the packages
shift
for pkg in "$@"; do
# Encode the package name for use in a URL
encoded_pkg=$(echo "$pkg" | sed 's|/|%2F|g')
# Fetch the list of all versions
versions=$(curl -s "https://registry.npmjs.org/$encoded_pkg" | jq -r '.versions | keys[]')
# Filter versions that match the tag part and get the last one
latest_prerelease_version=$(echo "$versions" | grep "$tag_part" | tail -n 1)
# Check if a version was found
if [[ ! -z $latest_prerelease_version ]]; then
# Append the package and version to the result string, separated by '@' and spaces between packages
result+="${pkg}@${latest_prerelease_version} "
else
echo "Latest pre-release version matching '$tag_part' for package ${pkg} could not be found." >&2
fi
done
# Trim the trailing space and print the result
echo "${result% }"
}
get_latest_copilotkit_prerelase_versions() {
get_latest_prerelease_versions $1 "@copilotkit/runtime" "@copilotkit/react-core" "@copilotkit/react-textarea" "@copilotkit/react-ui" "@copilotkit/shared"
}
use_local_packages() {
echo "Building local packages..."
pnpm -w freshbuild
echo "Done building local packages."
packages="file:$(pwd)/packages/runtime file:$(pwd)/packages/react-core file:$(pwd)/packages/react-textarea file:$(pwd)/packages/react-ui file:$(pwd)/packages/shared"
}
yarn_install_packages() {
local app_path="$1"
if [ -z "$packages" ]; then
use_local_packages;
fi
(cd "$app_path" && yarn add $packages)
info "Package manager: yarn"
info "Using CopilotKit packages: $packages"
}
npm_install_packages() {
local app_path="$1"
if [ -z "$packages" ]; then
use_local_packages;
fi
(cd "$app_path" && npm install $packages --save)
info "Package manager: npm"
info "Using CopilotKit packages: $packages"
}
+61
View File
@@ -0,0 +1,61 @@
source scripts/qa/lib/bash/qa.sh
source scripts/qa/lib/bash/packages.sh
prerelease_tag="$1"
packages=""
if [ -n "$prerelease_tag" ]; then
echo "Fetching pre-release CopilotKit packages..."
packages=$(get_latest_copilotkit_prerelase_versions "$prerelease_tag")
echo "Pre-release CopilotKit packages: $packages"
fi
if [ -z "$packages" ]; then
echo "No pre-release CopilotKit packages provided."
read -p "Enter package names separated by space or Enter to install local packages: " packages
fi
if [ -z "$packages" ]; then
echo "Installing local packages..."
else
echo "Installing packages: $packages"
fi
# only prompt for openai key if it is not set already
if [ -z "$OPENAI_API_KEY" ]; then
read -p "Enter OpenAI API key: " OPENAI_API_KEY
else
# Extract the first 5 characters of the API key
key_start=${OPENAI_API_KEY:0:5}
# Calculate the number of asterisks to print based on the key length
num_asterisks=$((${#OPENAI_API_KEY}-5))
asterisks=$(printf '%*s' "$num_asterisks" '' | tr ' ' '*')
echo "Using existing OPENAI_API_KEY: $key_start$asterisks"
fi
pid1=0
pid2=0
pid3=0
cleanup() {
if [ $pid1 -ne 0 ]; then
kill -9 $pid1 2>/dev/null || true
fi
if [ $pid2 -ne 0 ]; then
kill -9 $pid2 2>/dev/null || true
fi
if [ $pid3 -ne 0 ]; then
kill -9 $pid3 2>/dev/null || true
fi
killall next-server 2>/dev/null || true
}
# Trap Ctrl+C (INT signal) and exit
trap "echo 'Script interrupted.'; cleanup; exit" INT
trap "cleanup" EXIT
# Exit on any error
set -e
# record the current date + time
info "Test started at $(date)"
+47
View File
@@ -0,0 +1,47 @@
#!/bin/bash
# Get the current date in YYYY-MM-DD format
current_date=$(date +%Y-%m-%d)
# Define the file path with the current date
file_path="/tmp/qa-${current_date}.txt"
prompt() {
local prompt="$1"
local user_input
while true; do
# Display the prompt to the user and read a single character input
read -p "$prompt (y/n): " -n 1 user_input
echo # Move to a new line
# Check the user input and append the prompt to the file with the appropriate emoji
if [[ $user_input == "y" ]]; then
echo -e "$prompt" >> "$file_path" # Green checkmark emoji
break
elif [[ $user_input == "n" ]]; then
echo -e "$prompt" >> "$file_path" # Red X emoji
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
}
info() {
local info_msg="$1"
# Append the string to the file with the information emoji
echo -e "📢 $info_msg" >> "$file_path"
}
fail() {
local fail_msg="$1"
# Append the string to the file with the information emoji
echo -e "$fail_msg" >> "$file_path"
}
succeed() {
local success_msg="$1"
# Append the string to the file with the information emoji
echo -e "$success_msg" >> "$file_path"
}
+78
View File
@@ -0,0 +1,78 @@
"use client";
import {
CopilotKit,
useCopilotAction,
useCopilotReadable,
} from "@copilotkit/react-core";
import { CopilotTextarea } from "@copilotkit/react-textarea";
import { CopilotKitCSSProperties, 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);
},
render: (props) => {
return (
<div style={{ backgroundColor: "black", color: "white" }}>
<div>Status: {props.status}</div>
<div>Message: {props.args.message}</div>
</div>
);
},
},
[],
);
return (
<>
<div>{message}</div>
</>
);
}
export default function Home() {
return (
<div
style={
{
height: `100vh`,
"--copilot-kit-primary-color": "red",
} as CopilotKitCSSProperties
}
>
<CopilotKit url="/api/copilotkit/openai">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
icons={{
sendIcon: "📩",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
</div>
);
}
+6
View File
@@ -0,0 +1,6 @@
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
export async function POST(req: Request): Promise<Response> {
const copilotKit = new CopilotRuntime();
return copilotKit.response(req, new OpenAIAdapter({}));
}
+5
View File
@@ -0,0 +1,5 @@
{
"projects": {
"default": "copilotkit-test-12345"
}
}
+27
View File
@@ -0,0 +1,27 @@
{
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
],
"emulators": {
"functions": {
"port": 5001
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
+20
View File
@@ -0,0 +1,20 @@
/**
* Import function triggers from their respective submodules:
*
* import {onCall} from "firebase-functions/v2/https";
* import {onDocumentWritten} from "firebase-functions/v2/firestore";
*
* See a full list of supported triggers at https://firebase.google.com/docs/functions
*/
import { onRequest } from "firebase-functions/v2/https";
// import * as logger from "firebase-functions/logger";
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
// Start writing functions
// https://firebase.google.com/docs/functions/typescript
export const copilotKit = onRequest((request, response) => {
const copilotKit = new CopilotRuntime();
copilotKit.streamHttpServerResponse(request, response, new OpenAIAdapter({}));
});
+31
View File
@@ -0,0 +1,31 @@
{
"name": "functions",
"private": true,
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"@copilotkit/backend": "^0.7.0-mme-firebase-fixes.0",
"@copilotkit/react-core": "^0.23.0-mme-firebase-fixes.0",
"@copilotkit/react-textarea": "^0.33.0-mme-firebase-fixes.0",
"@copilotkit/react-ui": "^0.20.0-mme-firebase-fixes.0",
"@copilotkit/shared": "^0.7.0-mme-firebase-fixes.0",
"firebase-admin": "^12.0.0",
"firebase-functions": "^4.3.1"
},
"devDependencies": {
"firebase-functions-test": "^3.1.0",
"firebase-tools": "^13.6.0",
"typescript": "^5.4.3"
},
"engines": {
"node": "18"
}
}
+59
View File
@@ -0,0 +1,59 @@
"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 className="h-screen w-full flex items-center justify-center text-2xl">
{message}
</div>
);
}
export default function Home() {
return (
<CopilotKit url="http://127.0.0.1:5001/copilotkit-test-12345/us-central1/copilotKit">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
clickOutsideToClose={false}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": ["src"]
}
+74
View File
@@ -0,0 +1,74 @@
"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);
},
render: (props) => {
return (
<div style={{ backgroundColor: "black", color: "white" }}>
<div>Status: {props.status}</div>
<div>Message: {props.args.message}</div>
</div>
);
},
},
[],
);
return (
<>
<div>{message}</div>
{/* <CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/> */}
</>
);
}
export default function Home() {
return (
<CopilotKit url="/api/copilotkit/langchain">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+43
View File
@@ -0,0 +1,43 @@
import {
CopilotRuntime,
LangChainAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
} from "@copilotkit/runtime";
import { ChatOpenAI } from "@langchain/openai";
const runtime = new CopilotRuntime({
actions: [
{
name: "sayHello",
description: "Says hello to someone.",
parameters: [
{
name: "arg",
type: "string",
description: "The name of the person to say hello to.",
required: true,
},
],
handler: async ({ arg }) => {
console.log("Hello from the server", arg, "!");
},
},
],
});
const serviceAdapter = new LangChainAdapter({
chainFn: async ({ messages, tools }) => {
const model = new ChatOpenAI({ modelName: "gpt-4-1106-preview" }).bind(
tools as any,
);
return model.stream(messages);
},
});
export const { GET, POST, OPTIONS } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter,
endpoint: "/api/copilotkit/langchain",
debug: true,
}) as any;
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env python
"""Example LangChain server exposes multiple runnables (LLMs in this case)."""
from dotenv import load_dotenv
load_dotenv()
from fastapi import FastAPI
from langchain.chat_models import ChatOpenAI
from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings
from langchain.agents import AgentExecutor, tool
from langchain.tools.render import format_tool_to_openai_function
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain.agents.output_parsers import OpenAIFunctionsAgentOutputParser
from langchain.pydantic_v1 import BaseModel
from typing import Any
from langchain.agents.format_scratchpad import format_to_openai_functions
from langserve import add_routes
app = FastAPI(
title="LangChain Server",
version="1.0",
description="Spin up a simple api server using Langchain's Runnable interfaces",
)
# ChatOpenAI
# ----------
# We probably can't support ChatOpenAI...
# see input schema: http://localhost:8000/openai/input_schema
# also playground: http://localhost:8000/openai/playground/
# it looks tricky to support this in a generic way
add_routes(
app,
ChatOpenAI(),
path="/openai",
)
# Retriever
# ---------
# receives a single input VectorStoreRetrieverInput (type string)
# Input Schema: {"title":"VectorStoreRetrieverInput","type":"string"}
# according to the client docs, it can be called like this:
# - requests.post("http://localhost:8000/invoke", json={"input": "tree"})
# - remote_runnable.invoke("tree")
vectorstore = FAISS.from_texts(
["cats like fish", "dogs like sticks"], embedding=OpenAIEmbeddings()
)
retriever = vectorstore.as_retriever()
add_routes(
app,
retriever,
path="/retriever",
)
# Agent
# -----
# Input Schema: {"title":"Input","type":"object","properties":{"input":{"title":"Input","type":"string"}},"required":["input"]}
# - requests.post("http://localhost:8000/invoke", json={"input": {"input": "what does eugene think of cats?"}})
# - remote_runnable.invoke({"input": "what does eugene think of cats?"})
@tool
def get_eugene_thoughts(query: str) -> list:
"""Returns Eugene's thoughts on a topic."""
return retriever.get_relevant_documents(query)
tools = [get_eugene_thoughts]
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0, streaming=True)
llm_with_tools = llm.bind(functions=[format_tool_to_openai_function(t) for t in tools])
prompt = ChatPromptTemplate.from_messages(
[
("system", "You are a helpful assistant."),
("user", "{input}"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
]
)
agent = (
{
"input": lambda x: x["input"],
"agent_scratchpad": lambda x: format_to_openai_functions(
x["intermediate_steps"]
),
}
| prompt
| llm_with_tools
| OpenAIFunctionsAgentOutputParser()
)
agent_executor = AgentExecutor(graph=agent, tools=tools)
class Input(BaseModel):
input: str
class Output(BaseModel):
output: Any
add_routes(
app,
agent_executor.with_types(input_type=Input, output_type=Output).with_config(
{"run_name": "agent"}
),
path="/agent",
)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="localhost", port=8000)
+74
View File
@@ -0,0 +1,74 @@
"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);
},
render: (props) => {
return (
<div style={{ backgroundColor: "black", color: "white" }}>
<div>Status: {props.status}</div>
<div>Message: {props.args.message}</div>
</div>
);
},
},
[],
);
return (
<>
<div>{message}</div>
{/* <CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/> */}
</>
);
}
export default function Home() {
return (
<CopilotKit url="/api/copilotkit/openai">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+87
View File
@@ -0,0 +1,87 @@
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
} from "@copilotkit/runtime";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { ChatOpenAI } from "@langchain/openai";
const runtime = new CopilotRuntime({
actions: [
{
name: "sayHello",
description: "Says hello to someone.",
parameters: [
{
name: "name",
type: "string",
description: "The name of the person to say hello to.",
required: true,
},
],
handler: async ({ name }) => {
const prompt = ChatPromptTemplate.fromMessages([
[
"system",
"The user tells you their name. Say hello to the person in the most " +
" ridiculous way, roasting their name.",
],
["user", "My name is {name}"],
]);
const chain = prompt.pipe(new ChatOpenAI());
return chain.invoke({
name: name,
});
},
},
{
name: "sayGoodbye",
description: "Says goodbye to someone.",
parameters: [
{
name: "name",
type: "string",
description: "The name of the person to say goodbye to.",
required: true,
},
],
handler: async ({ name }) => {
const prompt = ChatPromptTemplate.fromMessages([
[
"system",
"The user tells you their name. Say goodbye to the person in the most " +
" ridiculous way, roasting their name.",
],
["user", "My name is {name}"],
]);
const chain = prompt.pipe(new ChatOpenAI());
return chain.stream({
name: name,
});
},
},
],
langserve: [
{
chainUrl: "http://localhost:8000/retriever",
name: "askAboutAnimals",
description:
"Always call this function if the users asks about a certain animal.",
},
{
chainUrl: "http://localhost:8000/agent",
name: "askAboutEugeneThoughts",
description:
"Always call this function if the users asks about Eugene's thoughts on a certain topic.",
},
],
});
const serviceAdapter = new OpenAIAdapter();
export const { GET, POST, OPTIONS } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter,
endpoint: "/api/copilotkit/openai",
debug: true,
}) as any;
@@ -0,0 +1,8 @@
python-dotenv
fastapi
langserve
langchain
langchain-cli
langchain-community
langchain-core
langchain-openai
+27
View File
@@ -0,0 +1,27 @@
/**
* @filePath pages/api/copilotkit.ts
*/
import { NextApiRequest, NextApiResponse } from "next";
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNextJSPagesRouterEndpoint,
} from "@copilotkit/runtime";
import OpenAI from "openai";
const openai = new OpenAI();
const serviceAdapter = new OpenAIAdapter({ openai });
const runtime = new CopilotRuntime();
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const handleRequest = copilotRuntimeNextJSPagesRouterEndpoint({
endpoint: "/api/copilotkit",
runtime,
serviceAdapter,
});
return await handleRequest(req, res);
};
export default handler;
+64
View File
@@ -0,0 +1,64 @@
import {
CopilotKit,
useCopilotAction,
useCopilotReadable,
} from "@copilotkit/react-core";
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!");
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);
},
render: (props) => {
return (
<div style={{ backgroundColor: "black", color: "white" }}>
<div>Status: {props.status}</div>
<div>Message: {props.args.message}</div>
</div>
);
},
},
[],
);
return (
<>
<div>{message}</div>
</>
);
}
export default function Home() {
return (
<CopilotKit runtimeUrl="/api/copilotkit">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+74
View File
@@ -0,0 +1,74 @@
"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);
},
render: (props) => {
return (
<div style={{ backgroundColor: "black", color: "white" }}>
<div>Status: {props.status}</div>
<div>Message: {props.args.message}</div>
</div>
);
},
},
[],
);
return (
<>
<div>{message}</div>
<CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/>
</>
);
}
export default function Home() {
return (
<CopilotKit url="/api/copilotkit/openai">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+25
View File
@@ -0,0 +1,25 @@
/**
* @filePath app/copilotkit/route.ts
*/
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
} from "@copilotkit/runtime";
import { NextRequest } from "next/server";
import OpenAI from "openai";
const openai = new OpenAI();
const serviceAdapter = new OpenAIAdapter({ openai });
const runtime = new CopilotRuntime();
export const POST = async (req: NextRequest) => {
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter,
endpoint: req.nextUrl.pathname,
});
return handleRequest(req);
};
+29
View File
@@ -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");
});
+58
View File
@@ -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>
);
}
+29
View File
@@ -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");
});
+82
View File
@@ -0,0 +1,82 @@
import type { MetaFunction } from "@remix-run/node";
import {
CopilotKit,
useCopilotAction,
useCopilotReadable,
} from "@copilotkit/react-core";
import { CopilotTextarea } from "@copilotkit/react-textarea";
import { CopilotSidebar } from "@copilotkit/react-ui";
import { useState } from "react";
import "@copilotkit/react-textarea/styles.css";
import "@copilotkit/react-ui/styles.css";
export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
];
};
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);
},
render: (props) => {
return (
<div style={{ backgroundColor: "black", color: "white" }}>
<div>Status: {props.status}</div>
<div>Message: {props.args.message}</div>
</div>
);
},
},
[],
);
return (
<>
<div>{message}</div>
<CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/>
</>
);
}
export default function Index() {
return (
<CopilotKit runtimeUrl="/copilotkit">
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+11
View File
@@ -0,0 +1,11 @@
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
import type { ActionFunctionArgs } from "@remix-run/node";
export async function action({ request }: ActionFunctionArgs) {
if (request.method !== "POST") {
return new Response("Method Not Allowed", { status: 405 });
}
const copilotKit = new CopilotRuntime();
return copilotKit.response(request, new OpenAIAdapter({}));
}
@@ -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" properties={{ userId: "xyz" }}>
<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,34 @@
import express from "express";
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNodeHttpEndpoint,
} from "@copilotkit/runtime";
const port = 4000;
var HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "X-Requested-With,content-type",
};
const handler = copilotRuntimeNodeHttpEndpoint({
endpoint: "/",
runtime: new CopilotRuntime(),
serviceAdapter: new OpenAIAdapter(),
});
const app = express();
app.use("/", (req, res, next) => {
if (req.method === "OPTIONS") {
res.writeHead(200, HEADERS);
res.end();
return;
}
return handler(req, res, next);
});
app.listen(port, () => {
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,25 @@
import express from "express";
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend";
const port = 4000;
var HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "X-Requested-With,content-type",
};
const app = express();
app.use("/", (req, res, next) => {
if (req.method === "OPTIONS") {
res.writeHead(200, HEADERS);
res.end();
return;
}
var copilotKit = new CopilotRuntime();
copilotKit.streamHttpServerResponse(req, res, new OpenAIAdapter(), HEADERS);
});
app.listen(port, () => {
console.log("Listening at http://localhost:4000/copilotkit");
});
@@ -0,0 +1,69 @@
"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>
<CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/>
</>
);
}
export default function Home() {
return (
<CopilotKit
runtimeUrl="/api/copilotkit/openai"
properties={{ userid: "abc_123" }}
>
<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,36 @@
import { NextRequest } from "next/server";
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
} from "@copilotkit/runtime";
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);
},
},
],
});
export const POST = async (req: NextRequest) => {
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter: new OpenAIAdapter(),
endpoint: req.nextUrl.pathname,
});
return handleRequest(req);
};
@@ -0,0 +1,66 @@
"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>
<CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/>
</>
);
}
export default function Home() {
return (
<CopilotKit runtimeUrl="/api/copilotkit/openai">
<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,26 @@
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend";
export async function POST(req: Request): Promise<Response> {
const copilotKit = new CopilotRuntime({
actions: [
{
name: "research",
description:
"Call this function to conduct research on a certain topic. Respect other notes about when to call this function",
parameters: [
{
name: "topic",
type: "string",
description: "The topic to research. 5 characters or longer.",
required: true,
},
],
handler: async ({ topic }) => {
console.log("Researching topic: ", topic);
return "The secret is xyz";
},
},
],
});
return copilotKit.response(req, new OpenAIAdapter({}));
}
@@ -0,0 +1,69 @@
"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>
<CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/>
</>
);
}
export default function Home() {
return (
<CopilotKit
runtimeUrl="/api/copilotkit/openai"
properties={{ userid: "abc_123" }}
>
<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,48 @@
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNextJSPagesRouterEndpoint,
} from "@copilotkit/runtime";
import { NextApiRequest, NextApiResponse } from "next";
const serviceAdapter = new OpenAIAdapter();
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.";
},
},
],
});
// This is required for file upload to work
export const config = {
api: {
bodyParser: false,
},
};
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const handleRequest = copilotRuntimeNextJSPagesRouterEndpoint({
endpoint: "/api/copilotkit",
runtime,
serviceAdapter,
});
return await handleRequest(req, res);
};
export default handler;
@@ -0,0 +1,66 @@
"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>
<CopilotTextarea
value={text}
onChange={(e) => setText(e.target.value)}
autosuggestionsConfig={{
textareaPurpose: "an outline of a presentation about elephants",
chatApiConfigs: {},
}}
/>
</>
);
}
export default function Home() {
return (
<CopilotKit runtimeUrl="/api/copilotkit/openai">
<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,12 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from "next";
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const copilotKit = new CopilotRuntime({});
copilotKit.streamHttpServerResponse(
req,
res,
new OpenAIAdapter({ model: "gpt-4o" }),
);
}
+58
View File
@@ -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" properties={{ userId: "xyz" }}>
<CopilotSidebar
defaultOpen={true}
labels={{
title: "Presentation Copilot",
initial: "Hi you! 👋 I can give you a presentation on any topic.",
}}
>
<InsideHome />
</CopilotSidebar>
</CopilotKit>
);
}
+33
View File
@@ -0,0 +1,33 @@
import * as http from "http";
import {
CopilotRuntime,
OpenAIAdapter,
copilotRuntimeNodeHttpEndpoint,
} from "@copilotkit/runtime";
const port = 4000;
var HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "X-Requested-With,content-type",
};
const handler = copilotRuntimeNodeHttpEndpoint({
endpoint: "/",
runtime: new CopilotRuntime(),
serviceAdapter: new OpenAIAdapter(),
});
var server = http.createServer(function (req, res) {
// Respond to OPTIONS (preflight) request
if (req.method === "OPTIONS") {
res.writeHead(200, HEADERS);
res.end();
return;
}
return handler(req, res);
});
server.listen(port, function () {
console.log(`Server running at http://localhost:${port}`);
});
+58
View File
@@ -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>
);
}
+22
View File
@@ -0,0 +1,22 @@
import * as http from "http";
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend";
const port = 4000;
var HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
"Access-Control-Allow-Headers": "X-Requested-With,content-type",
};
var server = http.createServer(function (req, res) {
// Respond to OPTIONS (preflight) request
if (req.method === "OPTIONS") {
res.writeHead(200, HEADERS);
res.end();
return;
}
var copilotKit = new CopilotRuntime();
copilotKit.streamHttpServerResponse(req, res, new OpenAIAdapter(), HEADERS);
});
server.listen(port, function () {
console.log(`Server running at http://localhost:${port}`);
});
+74
View File
@@ -0,0 +1,74 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
NEXT_PAGES_APP_PATH="/tmp/test-next-pages-app"
echo "Creating next app in $NEXT_PAGES_APP_PATH"
echo ""
# Remove prev project and run create-next-app
rm -rf $NEXT_PAGES_APP_PATH
npx create-next-app $NEXT_PAGES_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --no-app --import-alias="@/*"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $NEXT_PAGES_APP_PATH/.env
npm_install_packages $NEXT_PAGES_APP_PATH
cp scripts/qa/lib/next-pages/index.tsx $NEXT_PAGES_APP_PATH/src/pages/index.tsx
# Open VSCode
code $NEXT_PAGES_APP_PATH
prompt "Open index.tsx. Is it without errors in VSCode?"
cp scripts/qa/lib/next-pages/copilotkit.ts $NEXT_PAGES_APP_PATH/src/pages/api/copilotkit.ts
prompt "Open copilotkit.ts. Is it without errors in VSCode?"
# Temporarily disable -e
set +e
pushd $NEXT_PAGES_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
npm run dev > /dev/null 2>&1 &
pid1=$!
popd
prompt "Open http://localhost:3000. Is the page without errors?"
prompt "Chat to check if regular text and message history works (2x)?"
prompt "Ask the copilot to change the message. Is the message changed?"
prompt "Ask the copilot to change the message again. Is the message changed?"
prompt "Ask for a long message. Does the custom render work & stream?"
prompt "Does it provide the current message when asked?"
prompt "Test the keyboard shortcut cmd-\\ to open close the sidebar. Does it work?"
prompt "Does the text input autofocus when the sidebar is opened?"
prompt "In the text area, start a text about elephants. Does the autosuggestions work?"
killall next-server;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0
+102
View File
@@ -0,0 +1,102 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Read the package manager
read -p "Enter package manager (yarn/npm): " pkg_manager
if [ -z "$pkg_manager" ]; then
pkg_manager="npm"
fi
if [ "$pkg_manager" != "yarn" ] && [ "$pkg_manager" != "npm" ]; then
echo "Unsupported package manager. Exiting."
exit 1
fi
# Create the next app in /tmp
NEXT_APP_PATH="/tmp/test-next-app"
echo "Creating next app in $NEXT_APP_PATH"
echo ""
# Remove prev project and run create-next-app
rm -rf $NEXT_APP_PATH
if [ "$pkg_manager" = "yarn" ]; then
(cd /tmp && yarn create next-app $NEXT_APP_PATH --ts --eslint --no-tailwind --src-dir --app --import-alias="@/*")
elif [ "$pkg_manager" = "npm" ]; then
npx create-next-app $NEXT_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
fi
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $NEXT_APP_PATH/.env
if [ "$pkg_manager" = "yarn" ]; then
yarn_install_packages $NEXT_APP_PATH
elif [ "$pkg_manager" = "npm" ]; then
npm_install_packages $NEXT_APP_PATH
fi
cp scripts/qa/lib/next/page.tsx $NEXT_APP_PATH/src/app/page.tsx
# Open VSCode
code $NEXT_APP_PATH
prompt "Open page.tsx. Is it without errors in VSCode?"
mkdir -p $NEXT_APP_PATH/src/app/api/copilotkit/openai/
cp scripts/qa/lib/next/route.ts $NEXT_APP_PATH/src/app/api/copilotkit/openai/route.ts
prompt "Open route.ts. Is it without errors in VSCode?"
# Temporarily disable -e
set +e
pushd $NEXT_APP_PATH
if [ "$pkg_manager" = "yarn" ]; then
yarn build
elif [ "$pkg_manager" = "npm" ]; then
npm run build
fi
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
if [ "$pkg_manager" = "yarn" ]; then
yarn dev > /dev/null 2>&1 &
elif [ "$pkg_manager" = "npm" ]; then
npm run dev > /dev/null 2>&1 &
fi
pid1=$!
popd
prompt "Open http://localhost:3000. Is the page without errors?"
prompt "Chat to check if regular text and message history works (2x)?"
prompt "Ask the copilot to change the message. Is the message changed?"
prompt "Ask the copilot to change the message again. Is the message changed?"
prompt "Ask for a long message. Does the custom render work & stream?"
prompt "Does it provide the current message when asked?"
prompt "Test the keyboard shortcut cmd-\\ to open close the sidebar. Does it work?"
prompt "Does the text input autofocus when the sidebar is opened?"
prompt "In the text area, start a text about elephants. Do the autosuggestions work?"
prompt "Verify that the text area also completes text in the middle of the sentence."
killall next-server;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0
+64
View File
@@ -0,0 +1,64 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
NODE_APP_PATH="/tmp/test-node-app"
rm -rf $NODE_APP_PATH
echo "Creating node app in $NODE_APP_PATH"
# prepare the python app
mkdir -p $NODE_APP_PATH
npx create-next-app $NODE_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
npm_install_packages $NODE_APP_PATH
(cd $NODE_APP_PATH && npm install -D typescript ts-node @types/node)
cp scripts/qa/lib/node/page.tsx $NODE_APP_PATH/src/app/page.tsx
cp scripts/qa/lib/node/server.ts $NODE_APP_PATH/server.ts
# Temporarily disable -e
set +e
pushd $NODE_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
# Start next server
npm run dev > /dev/null 2>&1 &
pid1=$!
# Start node server
node npx ts-node server.ts > /dev/null 2>&1 &
pid2=$!
popd
prompt "Open http://localhost:3000. Is the page without errors?"
prompt "Chat with it. Does it work?"
prompt "Ask it to change the message. Does it work?"
killall next-server;
cleanup;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0;
+71
View File
@@ -0,0 +1,71 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
REMIX_APP_PATH="/tmp/test-remix-app"
echo "Creating remix app in $REMIX_APP_PATH"
echo ""
# Remove prev project and run create-next-app
npx create-remix@latest $REMIX_APP_PATH -y
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $REMIX_APP_PATH/.env
npm_install_packages $REMIX_APP_PATH
cp scripts/qa/lib/remix/_index.tsx $REMIX_APP_PATH/app/routes/_index.tsx
# Open VSCode
code $REMIX_APP_PATH
prompt "Open _index.tsx. Is it without errors in VSCode?"
cp scripts/qa/lib/remix/copilotkit.tsx $REMIX_APP_PATH/app/routes/copilotkit.tsx
prompt "Open copilotkit.tsx. Is it without errors in VSCode?"
# Temporarily disable -e
set +e
pushd $REMIX_APP_PATH
npm run build
exit_status=$?
if [ $exit_status -eq 0 ]; then
succeed "$pkg_manager build succeeded."
else
fail "$pkg_manager build failed with status $exit_status."
exit 1
fi
# Re-enable -e
set -e
npm run dev > /dev/null 2>&1 &
pid1=$!
popd
prompt "Open http://localhost:5173. Is the page without errors?"
prompt "Chat to check if regular text and message history works (2x)?"
prompt "Ask the copilot to change the message. Is the message changed?"
prompt "Ask the copilot to change the message again. Is the message changed?"
prompt "Ask for a long message. Does the custom render work & stream?"
prompt "Does it provide the current message when asked?"
prompt "Test the keyboard shortcut cmd-\\ to open close the sidebar. Does it work?"
prompt "Does the text input autofocus when the sidebar is opened?"
prompt "In the text area, start a text about elephants. Does the autosuggestions work?"
killall next-server;
succeed "Test completed successfully."
echo "===================="
echo "Test completed at $(date)"
echo "===================="
exit 0
+57
View File
@@ -0,0 +1,57 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
UPGRADE_EXPRESS_PATH="/tmp/upgrade-express"
rm -rf $UPGRADE_EXPRESS_PATH
echo "Creating express app for testing upgrade in $UPGRADE_EXPRESS_PATH"
mkdir -p $UPGRADE_EXPRESS_PATH
npx create-next-app $UPGRADE_EXPRESS_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
echo "Fetching released versions of CopilotKit packages..."
released_packages=$(get_latest_copilotkit_versions)
echo "Latest released versions: $released_packages"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $UPGRADE_EXPRESS_PATH/.env
(cd $UPGRADE_EXPRESS_PATH && npm install $released_packages --save)
(cd $UPGRADE_EXPRESS_PATH && npm install express)
(cd $UPGRADE_EXPRESS_PATH && npm i --save-dev @types/express)
echo "Using released CopilotKit packages: $released_packages"
echo "Testing upgrading to pre-release versions: $packages"
(cd $UPGRADE_EXPRESS_PATH && npm install -D typescript ts-node @types/node)
cp scripts/qa/lib/upgrade-express/old/page.tsx $UPGRADE_EXPRESS_PATH/src/app/page.tsx
cp scripts/qa/lib/upgrade-express/old/server.ts $UPGRADE_EXPRESS_PATH/server.ts
jq '. * {
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
}
}' $UPGRADE_EXPRESS_PATH/tsconfig.json > $UPGRADE_EXPRESS_PATH/temp.json && mv $UPGRADE_EXPRESS_PATH/temp.json $UPGRADE_EXPRESS_PATH/tsconfig.json
prompt "Check server.ts and page.tsx. Are they without errors in VSCode?"
echo "Upgrading packages"
(cd $UPGRADE_EXPRESS_PATH && npm install $packages --save)
cp scripts/qa/lib/upgrade-express/new/page.tsx $UPGRADE_EXPRESS_PATH/src/app/page.tsx
cp scripts/qa/lib/upgrade-express/new/server.ts $UPGRADE_EXPRESS_PATH/server.ts
prompt "Check server.ts and page.tsx again. Are they without errors in VSCode?"
echo "now run ts-node server.ts to test"
cleanup;
exit 0;
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
UPGRADE_NEXT_APP_ROUTER_PATH="/tmp/upgrade-next-app-router"
echo "Creating next app for testing upgrading next app router in $UPGRADE_NEXT_APP_ROUTER_PATH"
echo ""
# Remove prev project and run create-next-app
rm -rf $UPGRADE_NEXT_APP_ROUTER_PATH
npx create-next-app $UPGRADE_NEXT_APP_ROUTER_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
echo "Fetching released versions of CopilotKit packages..."
released_packages=$(get_latest_copilotkit_versions)
echo "Latest released versions: $released_packages"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $UPGRADE_NEXT_APP_ROUTER_PATH/.env
(cd $UPGRADE_NEXT_APP_ROUTER_PATH && npm install $released_packages --save)
echo "Using released CopilotKit packages: $released_packages"
echo "Testing upgrading to pre-release versions: $packages"
cp scripts/qa/lib/upgrade-next-app/old/page.tsx $UPGRADE_NEXT_APP_ROUTER_PATH/src/app/page.tsx
mkdir -p $UPGRADE_NEXT_APP_ROUTER_PATH/src/app/api/copilotkit/openai/
cp scripts/qa/lib/upgrade-next-app/old/route.ts $UPGRADE_NEXT_APP_ROUTER_PATH/src/app/api/copilotkit/openai/route.ts
# Open VSCode
code $UPGRADE_NEXT_APP_ROUTER_PATH
prompt "Check route.ts and page.tsx. Are they without errors in VSCode?"
echo "Upgrading packages"
(cd $UPGRADE_NEXT_APP_ROUTER_PATH && npm install $packages --save)
cp scripts/qa/lib/upgrade-next-app/new/page.tsx $UPGRADE_NEXT_APP_ROUTER_PATH/src/app/page.tsx
cp scripts/qa/lib/upgrade-next-app/new/route.ts $UPGRADE_NEXT_APP_ROUTER_PATH/src/app/api/copilotkit/openai/route.ts
prompt "Check route.ts and page.tsx again. Are they without errors in VSCode?"
cleanup;
exit 0
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
UPGRADE_NEXT_PAGES_ROUTER_PATH="/tmp/upgrade-next-pages-router"
echo "Creating next app for testing upgrading next pages router in $UPGRADE_NEXT_PAGES_ROUTER_PATH"
echo ""
# Remove prev project and run create-next-app
rm -rf $UPGRADE_NEXT_PAGES_ROUTER_PATH
npx create-next-app $UPGRADE_NEXT_PAGES_ROUTER_PATH --ts --eslint --use-npm --no-tailwind --src-dir --no-app --import-alias="@/*"
echo "Fetching released versions of CopilotKit packages..."
released_packages=$(get_latest_copilotkit_versions)
echo "Latest released versions: $released_packages"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $UPGRADE_NEXT_PAGES_ROUTER_PATH/.env
(cd $UPGRADE_NEXT_PAGES_ROUTER_PATH && npm install $released_packages --save)
echo "Using released CopilotKit packages: $released_packages"
echo "Testing upgrading to pre-release versions: $packages"
cp scripts/qa/lib/upgrade-next-pages/old/page.tsx $UPGRADE_NEXT_PAGES_ROUTER_PATH/src/pages/page.tsx
mkdir -p $UPGRADE_NEXT_PAGES_ROUTER_PATH/src/pages/api/copilotkit/openai/
cp scripts/qa/lib/upgrade-next-pages/old/route.ts $UPGRADE_NEXT_PAGES_ROUTER_PATH/src/pages/api/copilotkit/openai/route.ts
# Open VSCode
code $UPGRADE_NEXT_PAGES_ROUTER_PATH
prompt "Check route.ts and page.tsx. Are they without errors in VSCode?"
echo "Upgrading packages"
(cd $UPGRADE_NEXT_PAGES_ROUTER_PATH && npm install $packages --save)
cp scripts/qa/lib/upgrade-next-pages/new/page.tsx $UPGRADE_NEXT_PAGES_ROUTER_PATH/src/pages/page.tsx
cp scripts/qa/lib/upgrade-next-pages/new/route.ts $UPGRADE_NEXT_PAGES_ROUTER_PATH/src/pages/api/copilotkit/openai/route.ts
prompt "Check route.ts and page.tsx again. Are they without errors in VSCode?"
cleanup;
exit 0
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
source scripts/qa/lib/bash/prelude.sh
# Create the next app in /tmp
UPGRADE_NODE_APP_PATH="/tmp/upgrade-node"
rm -rf $UPGRADE_NODE_APP_PATH
echo "Creating node app for testing upgrade in $UPGRADE_NODE_APP_PATH"
mkdir -p $UPGRADE_NODE_APP_PATH
npx create-next-app $UPGRADE_NODE_APP_PATH --ts --eslint --use-npm --no-tailwind --src-dir --app --import-alias="@/*"
echo "Fetching released versions of CopilotKit packages..."
released_packages=$(get_latest_copilotkit_versions)
echo "Latest released versions: $released_packages"
# write to .env
echo "OPENAI_API_KEY=$OPENAI_API_KEY" > $UPGRADE_NODE_APP_PATH/.env
(cd $UPGRADE_NODE_APP_PATH && npm install $released_packages --save)
echo "Using released CopilotKit packages: $released_packages"
echo "Testing upgrading to pre-release versions: $packages"
(cd $UPGRADE_NODE_APP_PATH && npm install -D typescript ts-node @types/node)
cp scripts/qa/lib/upgrade-node/old/page.tsx $UPGRADE_NODE_APP_PATH/src/app/page.tsx
cp scripts/qa/lib/upgrade-node/old/server.ts $UPGRADE_NODE_APP_PATH/server.ts
jq '. * {
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
}
}' $UPGRADE_NODE_APP_PATH/tsconfig.json > $UPGRADE_NODE_APP_PATH/temp.json && mv $UPGRADE_NODE_APP_PATH/temp.json $UPGRADE_NODE_APP_PATH/tsconfig.json
prompt "Check server.ts and page.tsx. Are they without errors in VSCode?"
echo "Upgrading packages"
(cd $UPGRADE_NODE_APP_PATH && npm install $packages --save)
cp scripts/qa/lib/upgrade-node/new/page.tsx $UPGRADE_NODE_APP_PATH/src/app/page.tsx
cp scripts/qa/lib/upgrade-node/new/server.ts $UPGRADE_NODE_APP_PATH/server.ts
prompt "Check server.ts and page.tsx again. Are they without errors in VSCode?"
echo "now run ts-node server.ts to test"
cleanup;
exit 0;