Skip to content

Commit be3d09b

Browse files
committed
set up local mastra
1 parent 465811c commit be3d09b

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { LangGraphAgent } 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 { agenticChatMastraAgent } from "./local/mastra";
15+
import { LOCAL_MASTRA } from "./local/mastra";
1616

1717
export const agentsIntegrations: AgentIntegrationConfig[] = [
1818
{
@@ -71,9 +71,7 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
7171
{
7272
id: "mastra-agent-local",
7373
agents: async () => {
74-
return {
75-
agentic_chat: new MastraAgent({ agent: agenticChatMastraAgent("agentic_chat") }),
76-
};
74+
return MastraAgent.getLocalAgents({ mastra: LOCAL_MASTRA });
7775
},
7876
},
7977
{

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ import { openai } from "@ai-sdk/openai";
33
import { Agent } from "@mastra/core/agent";
44
import { Memory } from "@mastra/memory";
55
import { MockStore } from "@mastra/core/storage";
6+
import { Mastra } from "@mastra/core";
67

78
// import { weatherTool } from "../tools/weather-tool";
89

9-
export const agenticChatMastraAgent = (name: string) =>
10-
new Agent({
11-
name,
12-
instructions: `
13-
You are a helpful weather assistant that provides accurate weather information.
14-
15-
Your primary function is to help users get weather details for specific locations. When responding:
16-
- Always ask for a location if none is provided
17-
- If the location name isn’t in English, please translate it
18-
- If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
19-
- Include relevant details like humidity, wind conditions, and precipitation
20-
- Keep responses concise but informative
21-
22-
Use the weatherTool to fetch current weather data.
23-
`,
24-
model: openai("gpt-4o-mini"),
25-
// tools: { weatherTool },
26-
memory: new Memory({
27-
storage: new MockStore(),
10+
export const LOCAL_MASTRA = new Mastra({
11+
agents: {
12+
agentic_chat: new Agent({
13+
name: "agentic_chat",
14+
instructions: `
15+
You are a helpful weather assistant that provides accurate weather information.
16+
17+
Your primary function is to help users get weather details for specific locations. When responding:
18+
- Always ask for a location if none is provided
19+
- If the location name isn’t in English, please translate it
20+
- If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
21+
- Include relevant details like humidity, wind conditions, and precipitation
22+
- Keep responses concise but informative
23+
24+
Use the weatherTool to fetch current weather data.
25+
`,
26+
model: openai("gpt-4o-mini"),
27+
// tools: { weatherTool },
28+
memory: new Memory({
29+
storage: new MockStore(),
30+
}),
2831
}),
29-
});
32+
},
33+
});

0 commit comments

Comments
 (0)