forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
63 lines (57 loc) · 1.61 KB
/
Copy pathdemo.py
File metadata and controls
63 lines (57 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
This is a demo of the CopilotKit SDK.
"""
from fastapi import FastAPI
import uvicorn
from copilotkit.integrations.fastapi import add_fastapi_endpoint
from copilotkit import CopilotKitSDK, Action, LangGraphAgent
from copilotkit.demos.multi_agent.joke_agent import joke_graph
from copilotkit.demos.multi_agent.email_agent import email_graph
from copilotkit.demos.multi_agent.pirate_agent import pirate_graph
def greet_user(name):
"""Greet the user."""
print(f"Hello, {name}!")
return "The user has been greeted. Tell them to check the console."
app = FastAPI()
sdk = CopilotKitSDK(
actions=[
Action(
name="greet_user",
description="Greet the user.",
handler=greet_user,
parameters=[
{
"name": "name",
"description": "The name of the user to greet.",
"type": "string",
}
]
),
],
agents=[
LangGraphAgent(
name="joke_agent",
description="Make a joke.",
graph=joke_graph,
),
LangGraphAgent(
name="email_agent",
description="Write an email.",
graph=email_graph,
),
LangGraphAgent(
name="pirate_agent",
description="Speak like a pirate.",
graph=pirate_graph,
)
],
)
add_fastapi_endpoint(app, sdk, "/copilotkit")
def main():
"""Run the uvicorn server."""
uvicorn.run(
"copilotkit.demos.multi_agent.demo:app",
host="127.0.0.1",
port=8000,
reload=True
)