Skip to content
This repository was archived by the owner on Mar 12, 2026. It is now read-only.

Commit ffcbaf5

Browse files
committed
feat: more clean-up, introduce new hooks, better default styling
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
1 parent 6f06210 commit ffcbaf5

27 files changed

+623
-532
lines changed

apps/agent/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
It defines the workflow graph, state, tools, nodes and edges.
44
"""
55

6-
from langchain.agents import create_agent
76
from copilotkit import CopilotKitMiddleware
7+
from langchain.agents import create_agent
88
from langchain_openai import ChatOpenAI
9+
910
from src.query import query_data
10-
from src.todos import todo_tools, AgentState
11-
from src.middleware import DisableParallelToolCallsMiddleware
11+
from src.todos import AgentState, todo_tools
1212

1313
agent = create_agent(
14-
model=ChatOpenAI(model="gpt-4.1-mini"),
14+
model=ChatOpenAI(model="gpt-5-mini", reasoning={"effort": "low", "summary": "concise"}),
1515
tools=[query_data, *todo_tools],
16-
middleware=[DisableParallelToolCallsMiddleware(), CopilotKitMiddleware()],
16+
middleware=[CopilotKitMiddleware()],
1717
state_schema=AgentState,
18-
system_prompt=f"""
18+
system_prompt="""
1919
You are a helpful assistant that helps users understand CopilotKit and LangGraph used together.
2020
2121
Be brief in your explanations of CopilotKit and LangGraph, 1 to 2 sentences.
2222
2323
When demonstrating charts, always call the query_data tool to fetch all data from the database first.
24-
"""
24+
""",
2525
)
2626

2727
graph = agent

apps/agent/src/middleware.py

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

apps/agent/src/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
@tool
66
def query_data(query: str):
77
"""
8-
Query the database. Always call before showing a chart or graph.
8+
Query the database, takes natural language. Always call before showing a chart or graph.
99
"""
1010
csv_path = Path(__file__).parent / "db.csv"
1111
with open(csv_path) as f:
1212
reader = csv.DictReader(f)
13-
return list(reader)
13+
return list(reader)

apps/agent/src/todos.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from langchain.agents import AgentState as BaseAgentState
12
from langchain.tools import ToolRuntime, tool
23
from langchain.messages import ToolMessage
34
from langgraph.types import Command
@@ -11,7 +12,7 @@ class Todo(TypedDict):
1112
emoji: str
1213
status: Literal["pending", "completed"]
1314

14-
class AgentState(TypedDict):
15+
class AgentState(BaseAgentState):
1516
todos: list[Todo]
1617

1718
@tool
@@ -45,4 +46,4 @@ def get_todos(runtime: ToolRuntime):
4546
todo_tools = [
4647
manage_todos,
4748
get_todos,
48-
]
49+
]

apps/app/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@ag-ui/mcp-apps-middleware": "^0.0.3",
13-
"@copilotkit/react-core": "1.51.4",
14-
"@copilotkit/react-ui": "1.51.4",
15-
"@copilotkit/runtime": "1.51.4",
13+
"@copilotkit/react-core": "1.52.0-next.6",
14+
"@copilotkit/react-ui": "1.52.0-next.6",
15+
"@copilotkit/runtime": "1.52.0-next.6",
1616
"next": "16.1.6",
1717
"react": "^19.2.4",
1818
"react-dom": "^19.2.4",

apps/app/src/app/api/copilotkit/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const defaultAgent = new LangGraphAgent({
1515
});
1616

1717
// 2. Bind in middleware to the agent. For A2UI and MCP Apps.
18-
defaultAgent.use(...aguiMiddleware)
18+
defaultAgent.use(...aguiMiddleware);
1919

2020
// 3. Define the route and CopilotRuntime for the agent
2121
export const POST = async (req: NextRequest) => {

apps/app/src/app/globals.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
@import "tailwindcss";
22

3+
@custom-variant dark (&:where(.dark, .dark *));
4+
35
:root {
46
--background: #ffffff;
57
--foreground: #171717;
8+
--chart-tooltip-bg: #ffffff;
9+
--chart-tooltip-border: #e5e7eb;
10+
--chart-axis: #6b7280;
611
}
712

813
:root.dark {
914
--background: #0a0a0a;
1015
--foreground: #ededed;
16+
--chart-tooltip-bg: #27272a;
17+
--chart-tooltip-border: #3f3f46;
18+
--chart-axis: #a1a1aa;
1119
}
1220

1321
body {

apps/app/src/app/layout.tsx

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,20 @@
33
import "./globals.css";
44

55
import { CopilotKit } from "@copilotkit/react-core";
6-
import "@copilotkit/react-ui/v2/styles.css";
7-
import { useEffect } from "react";
6+
import "@copilotkit/react-core/v2/styles.css";
7+
import { ThemeProvider } from "@/hooks/use-theme";
88

99
export default function RootLayout({
1010
children,
1111
}: Readonly<{
1212
children: React.ReactNode;
1313
}>) {
14-
useEffect(() => {
15-
// Detect system preference and apply dark mode
16-
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
17-
if (isDark) {
18-
document.documentElement.classList.add('dark');
19-
}
20-
21-
// Listen for system preference changes
22-
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
23-
const handleChange = (e: MediaQueryListEvent) => {
24-
if (e.matches) {
25-
document.documentElement.classList.add('dark');
26-
} else {
27-
document.documentElement.classList.remove('dark');
28-
}
29-
};
30-
31-
mediaQuery.addEventListener('change', handleChange);
32-
return () => mediaQuery.removeEventListener('change', handleChange);
33-
}, []);
34-
3514
return (
3615
<html lang="en">
3716
<body className={`antialiased`}>
38-
<CopilotKit runtimeUrl="/api/copilotkit">
39-
{children}
40-
</CopilotKit>
17+
<ThemeProvider>
18+
<CopilotKit runtimeUrl="/api/copilotkit">{children}</CopilotKit>
19+
</ThemeProvider>
4120
</body>
4221
</html>
4322
);

apps/app/src/app/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { ExampleLayout } from "@/components/example-layout";
4-
import { Canvas } from "@/components/canvas";
4+
import { ExampleCanvas } from "@/components/example-canvas";
55
import { useGenerativeUIExamples, useExampleSuggestions } from "@/hooks";
66

77
import { CopilotChat } from "@copilotkit/react-core/v2";
@@ -18,7 +18,7 @@ export default function HomePage() {
1818
<ExampleLayout
1919
chatContent={<CopilotChat />}
2020
// chatContent={<HeadlessChat />}
21-
appContent={<Canvas />}
21+
appContent={<ExampleCanvas />}
2222
/>
2323
);
24-
}
24+
}

apps/app/src/components/canvas/index.tsx

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

0 commit comments

Comments
 (0)