CopilotKit

CopilotKit/CopilotKit
5684
627
51
627
45
30
MIT
A framework for building custom AI Copilots πŸ€– in-app AI chatbots, in-app AI Agents, & AI-powered Textareas.
2023-06-19EDT 04:Jun:th-14400
2024-05-04EDT 03:May:th-14400
2024-05-01EDT 21:May:st-14400
CopilotKit Logo

Discord GitHub CI

NPM MIT

The Open-Source Copilot Framework

Build, deploy, and operate fully custom AI Copilots.

in-app AI chatbots, AI agents, and AI Textareas.

Join our Discord  ·  Read the Docs  ·  Try Copilot Cloud



"Hello World" Templates

"Hello World" (A Todo App)
https://github.com/CopilotKit/example_app-todo

Todo App
PowerPoint + Copilot
https://github.com/CopilotKit/presentation-demo

Presentation-Demo
Spreadsheets + Copilot
https://github.com/CopilotKit/spreadsheet-demo

Presentation-Demo

Components

🌟 :
Build app-aware AI chatbots that can "see" the current app state + take action inside your app.
The AI chatbot can talk to your app frontend & backend, and to 3rd party services (Salesforce, Dropbox, etc.) via plugins.
Supports generative UI. Start in seconds:

🌟 :
Drop-in replacement for any <textarea />. AI-assisted text generation.
Autocompletions + AI editing + generate from scratch. Grounded on your users' data and Copilot application context.
Simply change textarea to CopilotTextarea.

🌟 In-App Agents (powered by LangChain):
Give agents access to realtime application context, and let agents take action inside applications.

🌟 Co-Agents (powered by LangChain. Coming soon.):
Allow end-users to observe and intervene in an in-app agent’s operations, with native application UX. End users can correct mistakes in intermediate steps if any were made, and restart agent operation from that point onwards.

How does it work

Define the following simple entry-points into your application, and the CopilotKitπŸͺ execution engine takes care of the rest!

  • Application state (frontend + backend + 3rd party)
  • Application interaction (via plain typescript code, frontend + backend)
  • Purpose-specific LLM chains
  • and more.

Installation

npm i @copilotkit/react-core @copilotkit/react-ui @copilotkit/react-textarea

Getting started

See quickstart in the docs

Demo

3-min showcase + 3-min implementation tutorial:

CopilotKit_Demo_Jan_zjgjk0.webm

Building blocks

A more comprehensive and up-to-date overview is available in the docs.
But roughtly:

Copilot entrypoints

  • βœ… useCopilotReadable: give frontend state to the copilot
  • βœ… useMakeCopilotDocumentReadable: give document state to the copilot, especially useful with 3rd party state (e.g. Gong call transcript).
  • βœ… useCopilotAction: frontend application interaction
  • βœ… CopilotRuntime: server side runtime
  • 🚧 useCopilotChain: provide usecase-specific LLM chains

Built-in UI components

  • βœ… <CopilotSidebar>: Built in, hackable Copilot UI (optional - you can bring your own UI).
  • βœ… <CopilotPopup>: Built in popup UI.
  • βœ… <CopilotChat>: Standalone chat UI
  • βœ… <CopilotTextarea />: drop-in <textarea /> replacement with Copilot autocompletions.
  • βœ… useCopilotChat() for fully-custom UI component
  • 🚧 use custom UX elements inside the chat (coming soon)

Examples

<CopilotSidebar />

import "@copilotkit/react-ui/styles.css"; // add to the app-global css
import { CopilotKit } from "@copilotkit/react-core";
import { CopilotSidebar } from "@copilotkit/react-ui";

function MyAmazingContent() {
  const importantInfo = useImportantInfo();
  useCopilotReadable({
    description: "Very important information",
    value: importantInfo,
  });

  useCopilotAction(
    {
      name: `selectDestinations_${toCamelCase(heading)}`,
      description: `Set the given destinations as 'selected', on the ${heading} table`,
      parameters: [
        {
          name: "destinationNames",
          type: "string[]",
          description: "The names of the destinations to select",
          required: true,
        },
      ],
      handler: async ({ destinationNames }) => {
        setCheckedRows((prevState) => {
          const newState = { ...prevState };
          destinationNames.forEach((destinationName) => {
            newState[destinationName] = true;
          });
          return newState;
        });
      },
    },
    []
  );

  return <YourContent />;
}

export default function App() {
  return (
    <CopilotKit url="/api/copilotkit/chat">
      {" "}
      {/* Global state & copilot logic. Put this around the entire app */}
      <CopilotSidebar>
        {" "}
        {/* A built-in Copilot UI (or bring your own UI). Put around individual pages, or the entire app. */}
        <MyAmazingContent />
      </CopilotSidebar>
    </CopilotKit>
  );
}

<CopilotTextarea />

A drop-in