/CopilotKit

πŸͺ The open-source copilot platform. Deeply integrate AI-tech into your application πŸ€–

Primary LanguageTypeScriptMIT LicenseMIT

CopilotKit Logo

Discord GitHub CI NPM MIT

The Open-Source Copilot Platform

Build, deploy, and operate best-in-class AI Copilots.

App-aware AI chatbots, AI agents, and AI Textareas
that can interact with your app based on context.

Reserve your place for Copilot Cloud (80 early adopter spots) Early registration closes Feb 22nd


Explore the docs Β»

Join our Discord Β· Website Β· Report Bug Β· Request Feature

Questions? Book a call with us Β»

Copilot support: We're happy to support your Copilot integration efforts.
You can receive support on our discord or by booking a call with us.



Templates

Todo App ("hello world")
https://github.com/CopilotKit/example_app-todo

Todo App
Presentation Demo:
https://github.com/CopilotKit/presentation-demo

Presentation-Demo

Components

🌟 <CopilotChat />:
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:

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>
  );

  // Now you can provide *context* entrypoints (frontend, backend, 3rd party),
  // *action* entrypoints (frontend, backend, 3rd party),
  // *agent* entrypoints (Copilot Skills, via LangChain / LangGraph).
  // and soon: co-agents.
  //
  // See below.

}

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

🌟 Copilot Skills (powered by LangChain):
Bring specialized LLM Chains and Graphs into in-app AI Copilot, with a few lines of code (native LangChain / LangGraph, or via LangServe). CopilotKit wraps your app, and routes relevant state as input to standalone skill chains (state can come from the frontend, backend, 3rd party integrations, or from the user). When the chain returns, the Copilot Engine funnels its output to in-app interaction as needed.

const copilotKit = new CopilotBackend({
   actions: [researchAgentNativeLangchain],
   langserve: [
    {
      chainUrl: "http://my-langserve.chain",
      name: "performResearch",
      description: "Performs research on a given topic.",
    }
  ],
});

🌟 Co-Agents (powered by LangChain):
Allow end-users to observe and intervene in an agent’s internal operations, with native application UX. For instance you can mark certain operations / data sources as sensitive- requiring explicit user approval before the agent carries out said operations (for instance removing an item from a CRM). Interventions can also happen retroactively: Co-agents allow end-users to review previously-run agent operations, identify and 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

  • βœ… useMakeCopilotReadable: give frontend state to the copilot
  • βœ… useMakeCopilotDocumentReadable: give document state to the copilot, especially useful with 3rd party state (e.g. Gong call transcript).
  • βœ… useMakeCopilotActionable: frontend application interaction
  • βœ… CopilotBackend: backend application interaction
  • 🚧 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()
    useMakeCopilotReadable("very importnat information: " + importantInfo)

    useMakeCopilotActionable(
      {
        name: `selectDestinations_${toCamelCase(heading)}`,
        description: `Set the given destinations as 'selected', on the ${heading} table`,
        argumentAnnotations: [
          {
            name: "destinationNames",
            type: "array",
            items: {
              type: "string",
            },
            description: "The names of the destinations to select",
            required: true,
          },
        ],
        implementation: async (destinationNames: string[]) => {
          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 <textarea /> replacement with autocompletions, AI insertions/edits, and generate-from-scratch.
Indexed on data provided to the Copilot.

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

// call ANYWHERE in your app to provide external context (make sure you wrap the app with a <CopilotKit >):
// See below for more features (parent/child hierarchy, categories, etc.)
useMakeCopilotReadable(relevantInformation);
useMakeCopilotDocumentReadable(document);

return (
  <CopilotKit url="/api/copilotkit/chat"> {/* Global state & copilot logic. Put this around the entire app */}
    <CopilotTextarea
      className="p-4 w-1/2 aspect-square font-bold text-3xl bg-slate-800 text-white rounded-lg resize-none"
      placeholder="A CopilotTextarea!"
      autosuggestionsConfig={{
        purposePrompt:
          "A COOL & SMOOTH announcement post about CopilotTextarea. Be brief. Be clear. Be cool.",
        forwardedParams: {
          // additional arguments to customize autocompletions
          max_tokens: 25,
          stop: ["\n", ".", ","],
        },
      }}
    />
  </CopilotKit>
);

Near-Term Roadmap

πŸ“Š Please vote on features via the Issues tab!

Copilot-App Interaction

  • βœ… useMakeCopilotReadable: give frontend state to the copilot
  • βœ… useMakeCopilotDocumentReadable: give document state to the copilot, especially useful with 3rd party state (e.g. Gong call transcript)
  • βœ… useMakeCopilotActionable: Let the copilot interact with the application
  • 🚧 useMakeCopilotAskable: let the copilot ask for additional information when needed (coming soon)
  • 🚧 useCopilotChain: provide usecase-specific chain
  • 🚧 useEditCopilotMessage: edit the (unsent) typed user message to the copilot (coming soon)
  • 🚧 copilot-assisted navigation: go to the best page to achieve some objective.
  • 🚧 Copilot Cloud: From hosting, chat history, analytics, and evals, to automatic Copilot personalization and self-improvement.

Integrations

  • βœ… Vercel AI SDK
  • βœ… OpenAI APIs
  • 🚧 Langchain
  • 🚧 Additional LLM providers

Frameworks

  • βœ… React
  • 🚧 Vue
  • 🚧 Svelte
  • 🚧 Swift (Mac + iOS)

Contribute

Contributions are welcome! πŸŽ‰

Join the Discord Discord

Contact

atai <at> copilotkit.ai