Skip to content

Commit 49289d8

Browse files
committed
getting started simplify
1 parent c9deecf commit 49289d8

1 file changed

Lines changed: 30 additions & 31 deletions

File tree

docs/content/docs/coagents/getting-started.mdx

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CoAgentsEnterpriseCTA } from "@/components/react/coagents/coagents-ente
66
import SelfHostingCopilotRuntimeCreateEndpoint from "@/snippets/self-hosting-copilot-runtime-create-endpoint.mdx";
77
import LLMAdapters from "@/snippets/llm-adapters.mdx";
88
import { CoAgentsDiagram } from "@/components/react/coagents/coagents-diagram.tsx";
9+
import FindCopilotRuntimeSnippet from "@/snippets/find-your-copilot-runtime.mdx";
910

1011

1112
## Before you start
@@ -55,41 +56,42 @@ At this point you should have CopilotKit hooked into your application, connected
5556

5657
The next step is to configure the Remote Endpoint to serve LangGraph agents.
5758

58-
**Modify your server.py file (setup in step (2)) to serve LangGraph agents:**
59+
First, find your `CopilotKitSDK` instance in your Python Remote Endpoint (typically `server.py`). <br/>
60+
**Then modify your `CopilotKitSDK` instance (setup in the previous step) to serve LangGraph agents:**
5961

6062
```python title="server.py"
61-
from fastapi import FastAPI
63+
from copilotkit import CopilotKitSDK, LangGraphAgent # [!code highlight]
64+
from .agent import the_langraph_graph # Import your LangGraph agent; in this example, it's the variable named `the_langraph_graph` in ./agent.py # [!code highlight]
6265
from copilotkit.integrations.fastapi import add_fastapi_endpoint
63-
from copilotkit import CopilotKitSDK, LangGraphAgent
66+
# ... other imports
6467

6568
app = FastAPI()
6669

67-
# Import your LangGraph agent; in this example, it's the variable
68-
# named `basic_agent_graph` in ./agent.py
69-
from .agent import basic_agent_graph
70+
# ...
7071

71-
# Initialize the agent for use by CopilotKit; we'll name it "basic_agent"
72-
basic_agent = LangGraphAgent( // [!code-highlight:4]
73-
name="basic_agent",
74-
description="Agent that asks about the weather",
75-
agent=basic_agent_graph,
72+
# Initialize the CopilotKit SDK
73+
sdk = CopilotKitSDK(
74+
agents=[ # [!code highlight:7]
75+
LangGraphAgent(
76+
name="basic_agent",
77+
description="Agent that answers questions about the weather",
78+
agent=the_langraph_graph,
79+
)
80+
],
81+
# ...
7682
)
7783

78-
# Initialize the CopilotKit SDK
79-
sdk = CopilotKitSDK(agents=[basic_agent]) [!code-highlight:1]
84+
# ...
8085

8186
# Add the CopilotKit endpoint to your FastAPI app
8287
add_fastapi_endpoint(app, sdk, "/copilotkit_remote")
8388

84-
def main():
85-
"""Run the uvicorn server."""
86-
import uvicorn
87-
uvicorn.run("server:app", host="127.0.0.1", port=8000, reload=True)
89+
# ...
8890

8991
```
9092

9193
<Callout>
92-
Remember the name `basic_agent` as well as our API endpoint URL (`http://localhost:8000/copilotkit_remote`), we'll need them as we move on to integrating this agent into the frontend.
94+
Remember the name `basic_agent`, we'll need it as we move on to integrating this agent into the frontend.
9395
</Callout>
9496

9597
</Step>
@@ -98,26 +100,23 @@ def main():
98100

99101
<Step>
100102

101-
## Agent-lock your Copilot to the `base_agent` agent.
103+
## Agent-lock your Copilot to the `basic_agent` agent.
102104

103105
CopilotKit supports router-mode as well as agent-lock mode. For more detail see [router-mode / agent-mode](/coagents/advanced/router-mode-agent-lock).
106+
In short: agent-lock modes locks your Copilot to a single LangGraph agent;
107+
router-mode automatically routes requests to the right agent based on the user's context and query.
104108

105-
In short: agent-lock modes locks your Copilot to a single LangGraph agent.
106-
Router-mode automatically routes requests to the right agent based on the user's context and query.
107-
108-
**For simplicity, wel'll use agent-lock mode in these tutorials,** but in production use-cases you will likely want to use router-mode.
109+
**For simplicity, we'll use agent-lock mode in these tutorials,** but in production use-cases you will likely want to use router-mode.
109110

110111
Lock the Copilot to the `basic_agent` setup earlier. This means every single interaction with the Copilot will be forwarded to the locked agent.
111112

112113
```tsx filename="src/page.tsx"
113-
// This UI will now invoke our AI agent, not just the LLM
114-
<CopilotKit runtimeUrl="/api/copilotkit" agent="basic_agent">
115-
<CopilotChat
116-
labels={{
117-
title: "Popup Assistant",
118-
initial: "Need any help?",
119-
}}
120-
/>
114+
// The Copilot will now invoke the LangGraph agent directly, not the Copilot router.
115+
<CopilotKit
116+
runtimeUrl="/api/copilotkit"
117+
agent="basic_agent" // agent-lock the Copilot, see 'agent-lock vs router-mode' // [!code highlight]
118+
>
119+
{...}
121120
</CopilotKit>
122121
```
123122

0 commit comments

Comments
 (0)