Add a powerful & hackable copilot to any app, in an afternoon.
CopilotKit in action.
pnpm install @copilotkit/react-core @copilotkit/react-ui
import { CopilotProvider } from "@copilotkit/react-core";
import { CopilotSidebarUIProvider } from "@copilotkit/react-ui";
export default function App(): JSX.Element {
return (
<CopilotProvider> {/* 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>
);
}
import { useMakeCopilotReadable } from "@copilotkit/react-core";
function Employee(props: EmployeeProps): JSX.Element {
const { employeeData, copilotParentPointer } = props;
// Give the copilot information about this employee, and associate it with its parent department.
useMakeCopilotReadable(employeeData.description(), copilotParentPointer);
return (
// Render as usual...
);
}
function Department(props: DepartmentProps): JSX.Element {
const { departmentData, employees } = props;
// Give the copilot information about this department. Keep the pointer, to associate employees w departments.
const departmentCopilotPointer = useMakeCopilotReadable(departmentData.description());
return ( // Render as usual.
<>
{employees.map((employeeData) => (
<Employee copilotParentPointer={departmentCopilotPointer} employeeData={employeeData} />
))}
</>
);
}
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 state - ✅
useMakeCopilotActionable
: Let the copilot take action on behalf of the user - 🚧
useMakeCopilotAskable
: let the copilot ask for additional information when needed (coming soon) - 🚧
useEditCopilotMessage
: edit the (unsent) typed user message to the copilot (coming soon) - 🚧 copilot-assisted navigation: go to the best page to achieve some objective.
- ✅
<CopilotSidebarUIProvider>
: Built in, hackable Copilot UI (optional - you can bring your own UI).
- ✅ Vercel AI SDK
- ✅ OpenAI APIs
- 🚧 Langchain
- 🚧 Additional LLM providers
- ✅ React
- 🚧 Vue
- 🚧 Svelte
- 🚧 Swift (Mac + iOS)
Contributions are welcome! 🎉