forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontend_tools.py
More file actions
25 lines (21 loc) · 927 Bytes
/
Copy pathfrontend_tools.py
File metadata and controls
25 lines (21 loc) · 927 Bytes
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
"""LangGraph agent backing the Frontend Tools demo.
This cell demonstrates `useFrontendTool` with a synchronous handler.
The backend graph registers no tools of its own — CopilotKit forwards
the frontend tool schema(s) to the agent at runtime, and the handler
executes in the browser. CopilotKitMiddleware is attached so frontend
tools, shared state, and agent context flow into every turn.
Like the sibling `frontend_tools_async` cell, the agent has no custom
behavior beyond a permissive system prompt — the demo's value is in
showing the wiring contract, not the agent logic.
"""
# region: middleware
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from copilotkit import CopilotKitMiddleware
graph = create_agent(
model=ChatOpenAI(model="gpt-5.4"),
tools=[],
middleware=[CopilotKitMiddleware()],
system_prompt="You are a helpful, concise assistant.",
)
# endregion