Skip to content

Commit c0c9bcf

Browse files
committed
Prepare dojo for deployment
1 parent 8cb2e7b commit c0c9bcf

File tree

14 files changed

+1221
-192
lines changed

14 files changed

+1221
-192
lines changed

typescript-sdk/apps/dojo/next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const withMDX = createMDX({
1616

1717
const nextConfig: NextConfig = {
1818
/* config options here */
19+
output: "standalone",
1920
// Configure pageExtensions to include md and mdx
2021
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
2122
webpack: (config, { isServer }) => {

typescript-sdk/apps/dojo/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
"@ag-ui/server-starter-all-features": "workspace:*",
2222
"@ag-ui/vercel-ai-sdk": "workspace:*",
2323
"@ai-sdk/openai": "^1.3.22",
24-
"@copilotkit/react-core": "1.8.14-next.4",
25-
"@copilotkit/react-ui": "1.8.14-next.4",
26-
"@copilotkit/runtime": "1.8.14-next.4",
27-
"@copilotkit/runtime-client-gql": "1.8.14-next.4",
28-
"@copilotkit/shared": "1.8.14-next.4",
24+
"@copilotkit/react-core": "1.9.2",
25+
"@copilotkit/react-ui": "1.9.2",
26+
"@copilotkit/runtime": "1.9.2",
27+
"@copilotkit/runtime-client-gql": "1.9.2",
28+
"@copilotkit/shared": "1.9.2",
2929
"@mastra/client-js": "^0.10.9",
3030
"@mastra/core": "^0.10.10",
31+
"@mastra/dynamodb": "^0.13.0",
3132
"@mastra/libsql": "^0.11.0",
3233
"@mastra/loggers": "^0.10.3",
3334
"@mastra/memory": "^0.11.1",

typescript-sdk/apps/dojo/src/agents.ts

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import { LangGraphAgent, LangGraphHttpAgent } from "@ag-ui/langgraph";
1212
import { AgnoAgent } from "@ag-ui/agno";
1313
import { LlamaIndexAgent } from "@ag-ui/llamaindex";
1414
import { CrewAIAgent } from "@ag-ui/crewai";
15+
import getEnvVars from "./env";
1516
import { mastra } from "./mastra";
1617
import { PydanticAIAgent } from "@ag-ui/pydantic-ai";
1718

19+
const envVars = getEnvVars();
1820
export const agentsIntegrations: AgentIntegrationConfig[] = [
1921
{
2022
id: "middleware-starter",
@@ -29,22 +31,22 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
2931
agents: async () => {
3032
return {
3133
agentic_chat: new PydanticAIAgent({
32-
url: "http://localhost:9000/agentic_chat/",
34+
url: `${envVars.pydanticAIUrl}/agentic_chat/`,
3335
}),
3436
agentic_generative_ui: new PydanticAIAgent({
35-
url: "http://localhost:9000/agentic_generative_ui/",
37+
url: `${envVars.pydanticAIUrl}/agentic_generative_ui/`,
3638
}),
3739
human_in_the_loop: new PydanticAIAgent({
38-
url: "http://localhost:9000/human_in_the_loop/",
40+
url: `${envVars.pydanticAIUrl}/human_in_the_loop/`,
3941
}),
4042
predictive_state_updates: new PydanticAIAgent({
41-
url: "http://localhost:9000/predictive_state_updates/",
43+
url: `${envVars.pydanticAIUrl}/predictive_state_updates/`,
4244
}),
4345
shared_state: new PydanticAIAgent({
44-
url: "http://localhost:9000/shared_state/",
46+
url: `${envVars.pydanticAIUrl}/shared_state/`,
4547
}),
4648
tool_based_generative_ui: new PydanticAIAgent({
47-
url: "http://localhost:9000/tool_based_generative_ui/",
49+
url: `${envVars.pydanticAIUrl}/tool_based_generative_ui/`,
4850
}),
4951
};
5052
},
@@ -53,7 +55,7 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
5355
id: "server-starter",
5456
agents: async () => {
5557
return {
56-
agentic_chat: new ServerStarterAgent({ url: "http://localhost:8000/" }),
58+
agentic_chat: new ServerStarterAgent({ url: envVars.serverStarterUrl }),
5759
};
5860
},
5961
},
@@ -62,22 +64,22 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
6264
agents: async () => {
6365
return {
6466
agentic_chat: new ServerStarterAllFeaturesAgent({
65-
url: "http://localhost:8000/agentic_chat",
67+
url: `${envVars.serverStarterAllFeaturesUrl}/agentic_chat`,
6668
}),
6769
human_in_the_loop: new ServerStarterAllFeaturesAgent({
68-
url: "http://localhost:8000/human_in_the_loop",
70+
url: `${envVars.serverStarterAllFeaturesUrl}/human_in_the_loop`,
6971
}),
7072
agentic_generative_ui: new ServerStarterAllFeaturesAgent({
71-
url: "http://localhost:8000/agentic_generative_ui",
73+
url: `${envVars.serverStarterAllFeaturesUrl}/agentic_generative_ui`,
7274
}),
7375
tool_based_generative_ui: new ServerStarterAllFeaturesAgent({
74-
url: "http://localhost:8000/tool_based_generative_ui",
76+
url: `${envVars.serverStarterAllFeaturesUrl}/tool_based_generative_ui`,
7577
}),
7678
shared_state: new ServerStarterAllFeaturesAgent({
77-
url: "http://localhost:8000/shared_state",
79+
url: `${envVars.serverStarterAllFeaturesUrl}/shared_state`,
7880
}),
7981
predictive_state_updates: new ServerStarterAllFeaturesAgent({
80-
url: "http://localhost:8000/predictive_state_updates",
82+
url: `${envVars.serverStarterAllFeaturesUrl}/predictive_state_updates`,
8183
}),
8284
};
8385
},
@@ -86,7 +88,7 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
8688
id: "mastra",
8789
agents: async () => {
8890
const mastraClient = new MastraClient({
89-
baseUrl: "http://localhost:4111",
91+
baseUrl: envVars.mastraUrl,
9092
});
9193

9294
return MastraAgent.getRemoteAgents({
@@ -113,27 +115,27 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
113115
agents: async () => {
114116
return {
115117
agentic_chat: new LangGraphAgent({
116-
deploymentUrl: "http://localhost:2024",
118+
deploymentUrl: envVars.langgraphUrl,
117119
graphId: "agentic_chat",
118120
}),
119121
agentic_generative_ui: new LangGraphAgent({
120-
deploymentUrl: "http://localhost:2024",
122+
deploymentUrl: envVars.langgraphUrl,
121123
graphId: "agentic_generative_ui",
122124
}),
123125
human_in_the_loop: new LangGraphAgent({
124-
deploymentUrl: "http://localhost:2024",
126+
deploymentUrl: envVars.langgraphUrl,
125127
graphId: "human_in_the_loop",
126128
}),
127129
predictive_state_updates: new LangGraphAgent({
128-
deploymentUrl: "http://localhost:2024",
130+
deploymentUrl: envVars.langgraphUrl,
129131
graphId: "predictive_state_updates",
130132
}),
131133
shared_state: new LangGraphAgent({
132-
deploymentUrl: "http://localhost:2024",
134+
deploymentUrl: envVars.langgraphUrl,
133135
graphId: "shared_state",
134136
}),
135137
tool_based_generative_ui: new LangGraphAgent({
136-
deploymentUrl: "http://localhost:2024",
138+
deploymentUrl: envVars.langgraphUrl,
137139
graphId: "tool_based_generative_ui",
138140
}),
139141
};
@@ -144,22 +146,22 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
144146
agents: async () => {
145147
return {
146148
agentic_chat: new LangGraphHttpAgent({
147-
url: "http://localhost:8000/agent/agentic_chat",
149+
url: `${envVars.langgraphFastApiUrl}/agent/agentic_chat`,
148150
}),
149151
agentic_generative_ui: new LangGraphHttpAgent({
150-
url: "http://localhost:8000/agent/agentic_generative_ui",
152+
url: `${envVars.langgraphFastApiUrl}/agent/agentic_generative_ui`,
151153
}),
152154
human_in_the_loop: new LangGraphHttpAgent({
153-
url: "http://localhost:8000/agent/human_in_the_loop",
155+
url: `${envVars.langgraphFastApiUrl}/agent/human_in_the_loop`,
154156
}),
155157
predictive_state_updates: new LangGraphHttpAgent({
156-
url: "http://localhost:8000/agent/predictive_state_updates",
158+
url: `${envVars.langgraphFastApiUrl}/agent/predictive_state_updates`,
157159
}),
158160
shared_state: new LangGraphHttpAgent({
159-
url: "http://localhost:8000/agent/shared_state",
161+
url: `${envVars.langgraphFastApiUrl}/agent/shared_state`,
160162
}),
161163
tool_based_generative_ui: new LangGraphHttpAgent({
162-
url: "http://localhost:8000/agent/tool_based_generative_ui",
164+
url: `${envVars.langgraphFastApiUrl}/agent/tool_based_generative_ui`,
163165
}),
164166
};
165167
},
@@ -169,7 +171,7 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
169171
agents: async () => {
170172
return {
171173
agentic_chat: new AgnoAgent({
172-
url: "http://localhost:8000/agui",
174+
url: `${envVars.agnoUrl}/agui`,
173175
}),
174176
};
175177
},
@@ -179,16 +181,16 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
179181
agents: async () => {
180182
return {
181183
agentic_chat: new LlamaIndexAgent({
182-
url: "http://localhost:9000/agentic_chat/run",
184+
url: `${envVars.llamaIndexUrl}/agentic_chat/run`,
183185
}),
184186
human_in_the_loop: new LlamaIndexAgent({
185-
url: "http://localhost:9000/human_in_the_loop/run",
187+
url: `${envVars.llamaIndexUrl}/human_in_the_loop/run`,
186188
}),
187189
agentic_generative_ui: new LlamaIndexAgent({
188-
url: "http://localhost:9000/agentic_generative_ui/run",
190+
url: `${envVars.llamaIndexUrl}/agentic_generative_ui/run`,
189191
}),
190192
shared_state: new LlamaIndexAgent({
191-
url: "http://localhost:9000/shared_state/run",
193+
url: `${envVars.llamaIndexUrl}/shared_state/run`,
192194
}),
193195
};
194196
},
@@ -198,22 +200,22 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
198200
agents: async () => {
199201
return {
200202
agentic_chat: new CrewAIAgent({
201-
url: "http://localhost:8000/agentic_chat",
203+
url: `${envVars.crewAiUrl}/agentic_chat`,
202204
}),
203205
human_in_the_loop: new CrewAIAgent({
204-
url: "http://localhost:8000/human_in_the_loop",
206+
url: `${envVars.crewAiUrl}/human_in_the_loop`,
205207
}),
206208
tool_based_generative_ui: new CrewAIAgent({
207-
url: "http://localhost:8000/tool_based_generative_ui",
209+
url: `${envVars.crewAiUrl}/tool_based_generative_ui`,
208210
}),
209211
agentic_generative_ui: new CrewAIAgent({
210-
url: "http://localhost:8000/agentic_generative_ui",
212+
url: `${envVars.crewAiUrl}/agentic_generative_ui`,
211213
}),
212214
shared_state: new CrewAIAgent({
213-
url: "http://localhost:8000/shared_state",
215+
url: `${envVars.crewAiUrl}/shared_state`,
214216
}),
215217
predictive_state_updates: new CrewAIAgent({
216-
url: "http://localhost:8000/predictive_state_updates",
218+
url: `${envVars.crewAiUrl}/predictive_state_updates`,
217219
}),
218220
};
219221
},

typescript-sdk/apps/dojo/src/app/[integrationId]/feature/human_in_the_loop/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const HumanInTheLoop: React.FC<HumanInTheLoopProps> = ({ params }) => {
2121
// agent lock to the relevant agent
2222
agent="human_in_the_loop"
2323
>
24-
<Chat />
24+
<Chat integrationId={integrationId} />
2525
</CopilotKit>
2626
);
2727
};
@@ -93,7 +93,9 @@ const InterruptHumanInTheLoop: React.FC<{
9393
);
9494
};
9595

96-
const Chat = () => {
96+
const Chat = ({ integrationId }: { integrationId: string }) => {
97+
// Langgraph uses it's own hook to handle human-in-the-loop interactions via langgraph interrupts,
98+
// This hook won't do anything for other integrations.
9799
useLangGraphInterrupt({
98100
render: ({ event, resolve }) => <InterruptHumanInTheLoop event={event} resolve={resolve} />,
99101
});
@@ -117,6 +119,9 @@ const Chat = () => {
117119
],
118120
},
119121
],
122+
// Langgraph uses it's own hook to handle human-in-the-loop interactions via langgraph interrupts,
123+
// so don't use this action for langgraph integration.
124+
available: ['langgraph', 'langgraph-fastapi'].includes(integrationId) ? 'disabled' : 'enabled',
120125
renderAndWaitForResponse: ({ args, respond, status }) => {
121126
return <StepsFeedback args={args} respond={respond} status={status} />;
122127
},

typescript-sdk/apps/dojo/src/env.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
type envVars = {
2+
serverStarterUrl: string;
3+
serverStarterAllFeaturesUrl: string;
4+
mastraUrl: string;
5+
langgraphUrl: string;
6+
langgraphFastApiUrl: string;
7+
agnoUrl: string;
8+
llamaIndexUrl: string;
9+
crewAiUrl: string;
10+
pydanticAIUrl: string;
11+
}
12+
13+
export default function getEnvVars(): envVars {
14+
return {
15+
serverStarterUrl: process.env.SERVER_STARTER_URL || 'http://localhost:8000',
16+
serverStarterAllFeaturesUrl: process.env.SERVER_STARTER_ALL_FEATURES_URL || 'http://localhost:8000',
17+
mastraUrl: process.env.MASTRA_URL || 'http://localhost:4111',
18+
langgraphUrl: process.env.LANGGRAPH_URL || 'http://localhost:2024',
19+
langgraphFastApiUrl: process.env.LANGGRAPH_FAST_API_URL || 'http://localhost:8000',
20+
agnoUrl: process.env.AGNO_URL || 'http://localhost:9001',
21+
llamaIndexUrl: process.env.LLAMA_INDEX_URL || 'http://localhost:9000',
22+
crewAiUrl: process.env.CREW_AI_URL || 'http://localhost:9002',
23+
pydanticAIUrl: process.env.PYDANTIC_AI_URL || 'http://localhost:9000',
24+
}
25+
}

typescript-sdk/apps/dojo/src/mastra/index.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,24 @@ import { openai } from "@ai-sdk/openai";
22
import { Agent } from "@mastra/core/agent";
33
import { Memory } from "@mastra/memory";
44
import { LibSQLStore } from "@mastra/libsql";
5+
import { DynamoDBStore } from "@mastra/dynamodb";
6+
57
import { Mastra } from "@mastra/core";
68
import { z } from "zod";
79

8-
// import { weatherTool } from "../tools/weather-tool";
10+
11+
let storage: LibSQLStore | DynamoDBStore
12+
13+
if (process.env.DYNAMODB_TABLE_NAME) {
14+
storage = new DynamoDBStore({
15+
name: "dynamodb",
16+
config: {
17+
tableName: process.env.DYNAMODB_TABLE_NAME
18+
},
19+
});
20+
} else {
21+
storage = new LibSQLStore({ url: "file::memory:" });
22+
}
923

1024
export const mastra = new Mastra({
1125
agents: {
@@ -24,9 +38,8 @@ export const mastra = new Mastra({
2438
Use the weatherTool to fetch current weather data.
2539
`,
2640
model: openai("gpt-4o"),
27-
// tools: { weatherTool },
2841
memory: new Memory({
29-
storage: new LibSQLStore({ url: "file::memory:" }),
42+
storage: storage,
3043
options: {
3144
workingMemory: {
3245
enabled: true,
@@ -53,7 +66,7 @@ export const mastra = new Mastra({
5366
`,
5467
model: openai("gpt-4o"),
5568
memory: new Memory({
56-
storage: new LibSQLStore({ url: "file::memory:" }),
69+
storage: storage,
5770
options: {
5871
workingMemory: {
5972
enabled: true,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__pycache__
2+
3+
# LangGraph API
4+
.langgraph_api
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Extracted from with-agno
2+
3+
To install deps
4+
pip install -r requirements.txt
5+
6+
to run
7+
python agent.py
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Example: Agno Agent with Finance tools
2+
3+
This example shows how to create an Agno Agent with tools (YFinanceTools) and expose it in an AG-UI compatible way.
4+
"""
5+
6+
from agno.agent.agent import Agent
7+
from agno.app.agui.app import AGUIApp
8+
from agno.models.openai import OpenAIChat
9+
from agno.tools.yfinance import YFinanceTools
10+
11+
agent = Agent(
12+
model=OpenAIChat(id="gpt-4o"),
13+
tools=[
14+
YFinanceTools(
15+
stock_price=True, analyst_recommendations=True, stock_fundamentals=True
16+
)
17+
],
18+
description="You are an investment analyst that researches stock prices, analyst recommendations, and stock fundamentals.",
19+
instructions="Format your response using markdown and use tables to display data where possible.",
20+
)
21+
22+
agui_app = AGUIApp(
23+
agent=agent,
24+
name="Investment Analyst",
25+
app_id="investment_analyst",
26+
description="An investment analyst that researches stock prices, analyst recommendations, and stock fundamentals.",
27+
)
28+
29+
app = agui_app.get_app()
30+
31+
if __name__ == "__main__":
32+
agui_app.serve(app="agent:app", host="0.0.0.0", port=9001, reload=True)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
agno>=1.6.3
2+
openai>=1.88.0
3+
yfinance>=0.2.63
4+
fastapi>=0.115.13
5+
uvicorn>=0.34.3
6+
ag-ui-protocol>=0.1.5

0 commit comments

Comments
 (0)