CopilotKit / CopilotKit
- ΡΡΠ±Π±ΠΎΡΠ°, 9 Π΄Π΅ΠΊΠ°Π±ΡΡ 2023β―Π³. Π² 00:00:04
Build in-app AI chatbots π€, and AI-powered Textareas β¨, into react web apps.
Explore the docs Β»
Join our Discord
Β·
Website
Β·
Report Bug
Β·
Request Feature
Questions?
Book a call with us Β»
π <CopilotPortal />:
Build in-app 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.
AI "second brain" for your users, on tap.
π <CopilotTextarea />:
AI-assisted text generation. Drop-in replacement for any <textarea />.
Autocompletions + AI editing + generate from scratch. Indexed on your users' content.
Starting with React. Use any LLM.
Combines frontend SDKs, backend SDKs, and (optional) cloud infrastructure. Open-source πͺ
<textarea />
replacement. Supports all <textarea />
customizations.useMakeCopilotReadable
and useMakeCopilotDocumentReadable
useMakeCopilotReadable
and useMakeCopilotDocumentReadable
)useMakeCopilotActionable
)2-min showcase + 2-min implementation tutorial:
npm i @copilotkit/react-core @copilotkit/react-ui @copilotkit/react-textarea
See quickstart in the docs
<CopilotTextarea />
A drop-in <textarea /> replacement with context-aware Copilot autocompletions.
purpose
prompt.useMakeCopilotReadable
ChatlikeApiEndpoint
<textarea />
customizationsimport "@copilotkit/react-textarea/styles.css"; // add to the app-global css
import { CopilotTextarea } from "@copilotkit/react-textarea";
import { CopilotProvider } from "@copilotkit/react-core";
// call ANYWHERE in your app to provide external context (make sure you wrap the app with a <CopilotProvider >):
// See below for more features (parent/child hierarchy, categories, etc.)
useMakeCopilotReadable(relevantInformation)
useMakeCopilotDocumentReadable(document)
return (
<CopilotProvider chatApiEndpoint="/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", ".", ","],
},
}}
/>
</CopilotProvider>
);
import "@copilotkit/react-ui/styles.css"; // add to the app-global css
import { CopilotProvider } from "@copilotkit/react-core";
import { CopilotSidebarUIProvider } from "@copilotkit/react-ui";
export default function App(): JSX.Element {
return (
<CopilotProvider chatApiEndpoint="/api/copilotkit/chat"> {/* Global state & copilot logic. Put this around the entire app */}
<CopilotSidebarUIProvider> {/* A built-in Copilot UI (or bring your own UI). Put around individual pages, or the entire app. */}
<YourContent />
</CopilotSidebarUIProvider>
</CopilotProvider>
);
}
CopilotSidebarUIProvider
UI -- or bring your own UI component.useMakeCopilotReadable
, useMakeCopilotActionable
, etc.parentId
useMakeCopilotReadable
works both with the sidekick, and with CopilotTextarea.
contextCategories: string[]
param to route information to different places.import { useMakeCopilotReadable } from "@copilotkit/react-core";
function Employee(props: EmployeeProps): JSX.Element {
const { employeeName, workProfile, metadata } = props;
// propagate any information copilot
const employeeContextId = useMakeCopilotReadable(employeeName);
// Pass a parentID to maintain a hiearchical structure.
// Especially useful with child React components, list elements, etc.
useMakeCopilotReadable(workProfile.description(), employeeContextId);
useMakeCopilotReadable(metadata.description(), employeeContextId);
return (
// Render as usual...
);
}
import { useMakeCopilotActionable } from "@copilotkit/react-core";
function Department(props: DepartmentProps): JSX.Element {
// ...
// Let the copilot take action on behalf of the user.
useMakeCopilotActionable(
{
name: "setEmployeesAsSelected",
description: "Set the given employees as 'selected'",
argumentAnnotations: [
{
name: "employeeIds",
type: "array", items: { type: "string" }
description: "The IDs of employees to set as selected",
required: true
}
],
implementation: async (employeeIds) => setEmployeesAsSelected(employeeIds),
},
[]
);
// ...
}
useMakeCopilotReadable
: give static information to the copilot, in sync with on-screen stateuseMakeCopilotActionable
: Let the copilot take action on behalf of the useruseMakeCopilotAskable
: let the copilot ask for additional information when needed (coming soon)useEditCopilotMessage
: edit the (unsent) typed user message to the copilot (coming soon)<CopilotSidebarUIProvider>
: Built in, hackable Copilot UI (optional - you can bring your own UI).<CopilotTextarea />
: drop-in <textarea />
replacement with Copilot autocompletions.Contributions are welcome! π
atai <at>
copilotkit.ai