Skip to content

Commit 9ba3771

Browse files
committed
example working
1 parent b8190c1 commit 9ba3771

File tree

8 files changed

+10
-20
lines changed

8 files changed

+10
-20
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OPENAI_API_KEY=""

integrations/mastra/typescript/examples/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"node": ">=22.13.0"
1616
},
1717
"dependencies": {
18-
"@ai-sdk/openai": "^2.0.23",
1918
"@mastra/client-js": "1.0.0-beta.2",
2019
"@mastra/core": "1.0.0-beta.2",
2120
"@mastra/libsql": "1.0.0-beta.0",

integrations/mastra/typescript/examples/src/mastra/agents/agentic-chat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { openai } from "@ai-sdk/openai";
21
import { Agent } from "@mastra/core/agent";
32
import { Memory } from "@mastra/memory";
43
import { LibSQLStore } from "@mastra/libsql";
@@ -18,10 +17,11 @@ export const agenticChatAgent = new Agent({
1817
1918
Use the weatherTool to fetch current weather data.
2019
`,
21-
model: openai("gpt-4o-mini"),
20+
model: "openai/gpt-4o-mini",
2221
tools: { weatherTool },
2322
memory: new Memory({
2423
storage: new LibSQLStore({
24+
id: 'agentic-chat-memory',
2525
url: "file:../mastra.db", // path is relative to the .mastra/output directory
2626
}),
2727
}),

integrations/mastra/typescript/examples/src/mastra/agents/backend-tool-rendering.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { openai } from "@ai-sdk/openai";
21
import { Agent } from "@mastra/core/agent";
32
import { Memory } from "@mastra/memory";
43
import { LibSQLStore } from "@mastra/libsql";
@@ -18,10 +17,11 @@ export const backendToolRenderingAgent = new Agent({
1817
1918
Use the get_weather tool to fetch current weather data.
2019
`,
21-
model: openai("gpt-4o-mini"),
20+
model: "openai/gpt-4o-mini",
2221
tools: { get_weather: weatherTool },
2322
memory: new Memory({
2423
storage: new LibSQLStore({
24+
id: 'backend-tool-rendering-memory',
2525
url: "file:../mastra.db", // path is relative to the .mastra/output directory
2626
}),
2727
}),

integrations/mastra/typescript/examples/src/mastra/agents/tool-based-generative-ui.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { openai } from "@ai-sdk/openai";
21
import { Agent } from "@mastra/core/agent";
32
import { Memory } from "@mastra/memory";
43
import { LibSQLStore } from "@mastra/libsql";
5-
import { createTool } from "@mastra/core";
6-
import z from "zod";
74

85
export const toolBasedGenerativeUIAgent = new Agent({
96
name: "Haiku Agent",
107
instructions: `
118
You are a helpful haiku assistant that provides the user with a haiku.
129
`,
13-
model: openai("gpt-4o-mini"),
10+
model: "openai/gpt-4o-mini",
1411
memory: new Memory({
1512
storage: new LibSQLStore({
13+
id: 'tool-based-generative-ui-memory',
1614
url: "file:../mastra.db", // path is relative to the .mastra/output directory
1715
}),
1816
}),

integrations/mastra/typescript/examples/src/mastra/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const mastra = new Mastra({
1717
backend_tool_rendering: backendToolRenderingAgent,
1818
},
1919
storage: new LibSQLStore({
20+
id: 'mastra-storage',
2021
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
2122
url: ":memory:",
2223
}),

integrations/mastra/typescript/examples/src/mastra/tools/weather-tool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export const weatherTool = createTool({
3535
conditions: z.string(),
3636
location: z.string(),
3737
}),
38-
execute: async ({ context }) => {
39-
return await getWeather(context.location);
38+
execute: async (inputData) => {
39+
return await getWeather(inputData.location);
4040
},
4141
});
4242

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)