Skip to content

Commit e76ca1a

Browse files
committed
docs(copilot-cloud): integrate copilot cloud into the documentation
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1 parent 912a264 commit e76ca1a

30 files changed

Lines changed: 635 additions & 310 deletions

docs/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_Zmxvd2luZy1ld2UtMzEuY2xlcmsuYWNjb3VudHMuZGV2JA"
1+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_Zmxvd2luZy1ld2UtMzEuY2xlcmsuYWNjb3VudHMuZGV2JA"
22
# NEXT_PUBLIC_POSTHOG_KEY="phc_XZdymVYjrph9Mi0xZYGNyCKexxgblXRR1jMENCtdz5Q"
33
# NEXT_PUBLIC_POSTHOG_HOST="https://eu.i.posthog.com"
44
# NEXT_PUBLIC_SCARF_PIXEL_ID="ffc9f65d-0186-4575-b065-61d62ea9d7d3"

docs/app/(home)/[[...slug]]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import { Cards, Card } from "fumadocs-ui/components/card";
2020
import { PropertyReference } from "@/components/react/property-reference";
2121
import { getImageMeta } from "fumadocs-ui/og";
2222
import { InsecurePasswordProtected } from "@/components/react/insecure-password-protected";
23+
import { LinkToCopilotCloud } from "@/components/react/link-to-copilot-cloud";
2324

2425
const mdxComponents = {
2526
...defaultMdxComponents,
2627
InsecurePasswordProtected: InsecurePasswordProtected,
28+
LinkToCopilotCloud: LinkToCopilotCloud,
2729
Tabs: Tabs,
2830
Tab: Tab,
2931
Steps: Steps,

docs/components/layout/top-bar.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"use client";
22
import { SearchIcon } from "lucide-react";
3+
// import { LinkToCopilotCloud } from "../react/link-to-copilot-cloud";
34

45
export function TopBar() {
56
return (
67
<>
7-
<div className="p-2 h-[60px] hidden lg:block justify-center absolute w-[calc(100vw-var(--fd-sidebar-width)-20px)] ml-[var(--fd-sidebar-width)]">
8-
<div className="flex justify-center">
8+
<div className="p-2 h-[60px] hidden lg:block absolute w-[calc(100vw-var(--fd-sidebar-width)-20px)] ml-[var(--fd-sidebar-width)]">
9+
<div className="flex justify-end items-center gap-4">
10+
{/* <LinkToCopilotCloud />
11+
<div className="h-8 border-l border-secondary-foreground/20 border-1.5" /> */}
912
<SearchToggle />
1013
</div>
1114
</div>
@@ -15,7 +18,7 @@ export function TopBar() {
1518

1619
export function SearchToggle() {
1720
return (
18-
<div onClick={toggleSearch} className="cursor-pointer h-10 absolute w-[400px] inline-flex items-center gap-2 border bg-fd-secondary/50 p-1.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground rounded-lg max-md:hidden">
21+
<div onClick={toggleSearch} className="cursor-pointer h-10 w-[400px] inline-flex items-center gap-2 border bg-fd-secondary/50 p-1.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground rounded-lg max-md:hidden">
1922
<SearchIcon className="w-4 h-4" />
2023
Search
2124
<div className="ms-auto inline-flex gap-0.5">
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"use client";
2+
3+
import { useEffect, useState } from "react";
4+
import Link from "next/link";
5+
import { useAuth } from "@clerk/nextjs";
6+
import posthog from "posthog-js";
7+
import { CloudIcon } from "lucide-react";
8+
9+
export function LinkToCopilotCloud({
10+
className,
11+
subPath,
12+
asButton = true,
13+
children
14+
}: {
15+
className?: string;
16+
subPath?: string;
17+
asButton?: boolean;
18+
children?: React.ReactNode;
19+
}) {
20+
const [isClient, setIsClient] = useState(false);
21+
const { userId } = useAuth();
22+
23+
useEffect(() => {
24+
setIsClient(true);
25+
}, []);
26+
27+
if (!isClient) {
28+
return null;
29+
}
30+
const url = new URL(`https://cloud.copilotkit.ai`);
31+
url.searchParams.set("ref", "docs");
32+
33+
const sessionId = posthog.get_session_id();
34+
35+
if (sessionId) {
36+
url.searchParams.set("session_id", sessionId);
37+
}
38+
39+
if (subPath) {
40+
url.pathname += subPath;
41+
}
42+
43+
let cn = `${className}`;
44+
45+
if (asButton) {
46+
cn = "text-indigo-800 ring-1 ring-indigo-200 dark:ring-indigo-900 dark:text-indigo-300 items-center bg-gradient-to-r from-indigo-200/50 to-purple-200/80 dark:from-indigo-900/40 dark:to-purple-900/50 flex p-1.5 px-4 rounded-md ";
47+
cn += "transition-all duration-100 hover:ring-2 hover:ring-indigo-400";
48+
} else {
49+
cn = "_text-primary-600 decoration-from-font underline [text-underline-position:from-font]";
50+
}
51+
52+
return (
53+
<Link
54+
href={url.toString()}
55+
target="_blank"
56+
className={cn}
57+
>
58+
{asButton ? <CloudIcon className="w-5 h-5 mr-2" /> : null}
59+
{
60+
children ? children : userId ? "Go to Copilot Cloud" : "Sign up for Copilot Cloud"
61+
}
62+
</Link>
63+
);
64+
}

docs/content/docs/(root)/guides/backend-actions/langgraph-platform-endpoint.mdx

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ title: "Remote Endpoint (LangGraph Platform)"
33
description: "Connect your CopilotKit application to an agent deployed on LangGraph Platform."
44
---
55
import FindCopilotRuntimeSnippet from "@/snippets/find-your-copilot-runtime.mdx";
6+
import { Accordions, Accordion } from "fumadocs-ui/components/accordion";
7+
import { TailoredContent, TailoredContentOption } from "@/components/react/tailored-content.tsx";
8+
import CopilotCloudConfigureRemoteEndpointLangGraphSnippet from "@/snippets/copilot-cloud-configure-remote-endpoint-langgraph.mdx";
9+
import CopilotCloudConfigureCopilotkitProviderSnippet from "@/snippets/copilot-cloud-configure-copilotkit-provider.mdx";
10+
import LangGraphPlatformDeploymentTabs from "@/snippets/langgraph-platform-deployment-tabs.mdx";
11+
import { FaCloud, FaServer } from "react-icons/fa";
612

713
<Callout type="info">
814
This guide assumes you've created a LangGraph agent, and have a `langgraph.json` file set up. If you need a quick introduction, check out [this brief example
@@ -13,43 +19,68 @@ import FindCopilotRuntimeSnippet from "@/snippets/find-your-copilot-runtime.mdx"
1319
<Steps>
1420

1521
<Step>
16-
### Deploy your agent to LangGraph Platform
22+
### Deploy your agent
1723

18-
To integrate an agent CopilotKit application, it needs to be deployed to the LangGraph Platform.<br/>
19-
Please follow [the official LangGraph Cloud deployment guide](https://langchain-ai.github.io/langgraph/cloud/deployment/cloud/).<br /><br />
20-
A successful deployment would yield a an API URL (often referred here as "deployment URL") in the following format: `https://{project-identifiers}.langgraph.app`. You'll need this later.
24+
First, you need to host your agent so that CopilotKit can access it.
2125

26+
<LangGraphPlatformDeploymentTabs components={props.components} />
2227
</Step>
2328

2429
<Step>
25-
### Connect the app to the remote endpoint
26-
Now that you've deployed your agent to LangGraph Platform, integrate it into your CopilotKit application by modifying your CopilotRuntime configuration.<br />
27-
28-
First, find your CopilotRuntime instance in your code.
29-
</Step>
30-
31-
<Step>
32-
33-
Update the `CopilotRuntime` config to include the `remoteEndpoints` property:
34-
35-
```tsx
36-
const runtime = new CopilotRuntime({
37-
// ...existing configuration
38-
remoteEndpoints: [ // [!code highlight:9]
39-
langGraphPlatformEndpoint({
40-
deploymentUrl: "your-api-url",
41-
langsmithApiKey: "your-langsmith-api-key",
42-
// List of all agents which are available under "graphs" list in your langgraph.json file.
43-
agents: [{ name: 'my_agent', description: 'A helpful LLM agent' }]
44-
}),
45-
],
46-
});
47-
```
48-
49-
<Callout type="info">
50-
Tip: Use the `langGraphPlatformEndpoint` type constructor function
51-
</Callout>
52-
30+
### Setup your Copilot Runtime
31+
32+
<TailoredContent>
33+
<TailoredContentOption
34+
title="Copilot Cloud (Recommended)"
35+
description="I'm already using or want to use Copilot Cloud."
36+
icon={<FaCloud />}
37+
>
38+
<InsecurePasswordProtected>
39+
If you followed the [Copilot Cloud Quickstart](/docs/quickstart) and opted to use CopilotCloud,
40+
you only need to add your LangGraph Platform deployment URL and LangSmith API key to your CopilotCloud.
41+
42+
<Accordions className="my-4">
43+
<Accordion title="Haven't setup Copilot Cloud yet? Click here!" >
44+
Copilot Cloud hooks into your CopilotKit provider, so you'll need to set it up first if you haven't already.
45+
<CopilotCloudConfigureCopilotkitProviderSnippet components={props.components} />
46+
</Accordion>
47+
</Accordions>
48+
<CopilotCloudConfigureRemoteEndpointLangGraphSnippet components={props.components} />
49+
</InsecurePasswordProtected>
50+
</TailoredContentOption>
51+
<TailoredContentOption
52+
title="Self-Hosted"
53+
description="I'm using or want to use a self-hosted Copilot Runtime."
54+
icon={<FaServer />}
55+
>
56+
<Steps>
57+
<Step>
58+
<FindCopilotRuntimeSnippet components={props.components} />
59+
</Step>
60+
<Step>
61+
Update the `CopilotRuntime` config to include the `remoteEndpoints` property:
62+
63+
```tsx
64+
const runtime = new CopilotRuntime({
65+
// ...existing configuration
66+
remoteEndpoints: [ // [!code highlight:9]
67+
langGraphPlatformEndpoint({
68+
deploymentUrl: "your-api-url",
69+
langsmithApiKey: "your-langsmith-api-key",
70+
// List of all agents which are available under "graphs" list in your langgraph.json file.
71+
agents: [{ name: 'my_agent', description: 'A helpful LLM agent' }]
72+
}),
73+
],
74+
});
75+
```
76+
77+
<Callout type="info">
78+
Tip: Use the `langGraphPlatformEndpoint` type constructor function
79+
</Callout>
80+
</Step>
81+
</Steps>
82+
</TailoredContentOption>
83+
</TailoredContent>
5384
</Step>
5485

5586
<Step>

docs/content/docs/(root)/guides/backend-actions/remote-backend-endpoint.mdx

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ title: "Remote Endpoint (Python)"
33
description: "Connect your CopilotKit application to a remote backend endpoint, allowing integration with Python-based services or other non-Node.js backends."
44
---
55
import FindCopilotRuntimeSnippet from "@/snippets/find-your-copilot-runtime.mdx";
6+
import CopilotCloudConfigureRemoteEndpointSnippet from "@/snippets/copilot-cloud-configure-remote-endpoint.mdx";
7+
import CopilotCloudConfigureCopilotkitProviderSnippet from "@/snippets/copilot-cloud-configure-copilotkit-provider.mdx";
8+
import { TailoredContent, TailoredContentOption } from "@/components/react/tailored-content";
9+
import { Accordions, Accordion } from "fumadocs-ui/components/accordion";
10+
import { FaCloud, FaServer } from "react-icons/fa";
611

712

813
## Stand up a FastAPI server using the CopilotKit Python SDK
@@ -185,42 +190,51 @@ Since we've added the entry point in `server.py`, you can run your FastAPI serve
185190

186191
Now that you've set up your FastAPI server with the backend actions, integrate it into your CopilotKit application by modifying your `CopilotRuntime` configuration.
187192

193+
<TailoredContent>
194+
<TailoredContentOption
195+
title="Copilot Cloud (Recommended)"
196+
description="I want to use Copilot Cloud to serve my remote endpoint."
197+
icon={<FaCloud />}
198+
>
199+
<InsecurePasswordProtected>
200+
<CopilotCloudConfigureRemoteEndpointSnippet components={props.components} />
201+
</InsecurePasswordProtected>
202+
</TailoredContentOption>
203+
<TailoredContentOption
204+
title="Self-Hosted"
205+
description="I want to use a self-hosted Copilot Runtime to serve my remote endpoint."
206+
icon={<FaServer />}
207+
>
208+
<Steps>
209+
<Step>
210+
<FindCopilotRuntimeSnippet components={props.components} />
211+
</Step>
212+
<Step>
213+
Update the `CopilotRuntime` to include your new `remote endpoint`.
214+
215+
```tsx
216+
const runtime = new CopilotRuntime({
217+
// ...existing configuration
218+
remoteEndpoints: [ // [!code highlight:5]
219+
{ url: "http://localhost:8000/copilotkit_remote" },
220+
],
221+
});
222+
```
223+
</Step>
224+
</Steps>
225+
226+
## Troubleshooting
227+
228+
A few things to try if you are running into trouble:
229+
230+
1. Make sure there is no other local application server running on the 8000 port.
231+
2. Under `/agent/my_agent/demo.py`, change host from `0.0.0.0` to `127.0.0.1` or to `localhost`
232+
233+
</TailoredContentOption>
234+
</TailoredContent>
188235

189-
<Steps>
190-
<Step>
191-
<FindCopilotRuntimeSnippet />
192-
</Step>
193-
194-
<Step>
195-
196-
Update the `CopilotRuntime` config to include the `remoteEndpoints` property:
197-
198-
```tsx
199-
const runtime = new CopilotRuntime({
200-
// ...existing configuration
201-
remoteEndpoints: [ // [!code highlight:5]
202-
{
203-
url: "http://localhost:8000/copilotkit_remote",
204-
},
205-
],
206-
});
207-
```
208-
</Step>
209-
210-
<Step>
211236
### Test Your Implementation
212237

213238
After setting up the remote endpoint and modifying your `CopilotRuntime`, you can test your implementation by asking the copilot to perform actions that invoke your Python backend. For example, ask the copilot: "Fetch the name for user ID `123`."
214239

215-
</Step>
216-
217-
</Steps>
218-
219240
---
220-
221-
## Troubleshooting
222-
223-
A few things to try if you are running into trouble:
224-
225-
1. Make sure there is no other local application server running on the 8000 port.
226-
2. Under `/agent/my_agent/demo.py`, change host from `0.0.0.0` to `127.0.0.1` or to `localhost`

docs/content/docs/(root)/guides/custom-look-and-feel/headless-ui.mdx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,33 @@ title: "Headless UI (Fully Custom)"
33
description: "Fully customize your Copilot's UI from the ground up using headless UI"
44
---
55

6-
For documentation on using the headless UI to build fully custom Copilot interfaces, please see the [Headless UI guide](/guides/headless-ui).
6+
The built-in Copilot UI can be customized in many ways -- both through css and by passing in custom sub-components.
7+
8+
CopilotKit also offers **fully custom headless UI**, through the `useCopilotChat` hook. Everything built with the built-in UI (and more) can be implemented with the headless UI, providing deep customizability.
9+
10+
```tsx
11+
import { useCopilotChat } from "@copilotkit/react-core";
12+
import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
13+
14+
export function CustomChatInterface() {
15+
const {
16+
visibleMessages,
17+
appendMessage,
18+
setMessages,
19+
deleteMessage,
20+
reloadMessages,
21+
stopGeneration,
22+
isLoading,
23+
} = useCopilotChat();
24+
25+
const sendMessage = (content: string) => {
26+
appendMessage(new TextMessage({ content, role: Role.User }));
27+
};
28+
29+
return (
30+
<div>
31+
{/* Implement your custom chat UI here */}
32+
</div>
33+
);
34+
}
35+
```

docs/content/docs/(root)/guides/headless-ui.mdx

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)