create-mastra 0.0.0-support-d1-client-20250701191943 → 0.0.0-tool-call-parts-20250630193309
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +60 -52
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1544,16 +1544,14 @@ var getProviderImportAndModelItem = (llmProvider) => {
|
|
|
1544
1544
|
async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
1545
1545
|
const { providerImport, modelItem } = getProviderImportAndModelItem(llmProvider);
|
|
1546
1546
|
const instructions = `
|
|
1547
|
-
You are a helpful weather assistant that provides accurate weather information
|
|
1547
|
+
You are a helpful weather assistant that provides accurate weather information.
|
|
1548
1548
|
|
|
1549
1549
|
Your primary function is to help users get weather details for specific locations. When responding:
|
|
1550
1550
|
- Always ask for a location if none is provided
|
|
1551
|
-
- If the location name isn
|
|
1551
|
+
- If the location name isn\u2019t in English, please translate it
|
|
1552
1552
|
- If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
|
|
1553
1553
|
- Include relevant details like humidity, wind conditions, and precipitation
|
|
1554
1554
|
- Keep responses concise but informative
|
|
1555
|
-
- If the user asks for activities and provides the weather forecast, suggest activities based on the weather forecast.
|
|
1556
|
-
- If the user asks for activities, respond in the format they request.
|
|
1557
1555
|
|
|
1558
1556
|
${addExampleTool ? "Use the weatherTool to fetch current weather data." : ""}
|
|
1559
1557
|
`;
|
|
@@ -1583,10 +1581,63 @@ export const weatherAgent = new Agent({
|
|
|
1583
1581
|
await fs4.writeFile(destPath, "");
|
|
1584
1582
|
await fs4.writeFile(destPath, formattedContent);
|
|
1585
1583
|
}
|
|
1586
|
-
async function writeWorkflowSample(destPath) {
|
|
1587
|
-
const
|
|
1584
|
+
async function writeWorkflowSample(destPath, llmProvider) {
|
|
1585
|
+
const { providerImport, modelItem } = getProviderImportAndModelItem(llmProvider);
|
|
1586
|
+
const content = `${providerImport}
|
|
1587
|
+
import { Agent } from '@mastra/core/agent';
|
|
1588
|
+
import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
1588
1589
|
import { z } from 'zod';
|
|
1589
1590
|
|
|
1591
|
+
const llm = ${modelItem};
|
|
1592
|
+
|
|
1593
|
+
const agent = new Agent({
|
|
1594
|
+
name: 'Weather Agent',
|
|
1595
|
+
model: llm,
|
|
1596
|
+
instructions: \`
|
|
1597
|
+
You are a local activities and travel expert who excels at weather-based planning. Analyze the weather data and provide practical activity recommendations.
|
|
1598
|
+
|
|
1599
|
+
For each day in the forecast, structure your response exactly as follows:
|
|
1600
|
+
|
|
1601
|
+
\u{1F4C5} [Day, Month Date, Year]
|
|
1602
|
+
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
1603
|
+
|
|
1604
|
+
\u{1F321}\uFE0F WEATHER SUMMARY
|
|
1605
|
+
\u2022 Conditions: [brief description]
|
|
1606
|
+
\u2022 Temperature: [X\xB0C/Y\xB0F to A\xB0C/B\xB0F]
|
|
1607
|
+
\u2022 Precipitation: [X% chance]
|
|
1608
|
+
|
|
1609
|
+
\u{1F305} MORNING ACTIVITIES
|
|
1610
|
+
Outdoor:
|
|
1611
|
+
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1612
|
+
Best timing: [specific time range]
|
|
1613
|
+
Note: [relevant weather consideration]
|
|
1614
|
+
|
|
1615
|
+
\u{1F31E} AFTERNOON ACTIVITIES
|
|
1616
|
+
Outdoor:
|
|
1617
|
+
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1618
|
+
Best timing: [specific time range]
|
|
1619
|
+
Note: [relevant weather consideration]
|
|
1620
|
+
|
|
1621
|
+
\u{1F3E0} INDOOR ALTERNATIVES
|
|
1622
|
+
\u2022 [Activity Name] - [Brief description including specific venue]
|
|
1623
|
+
Ideal for: [weather condition that would trigger this alternative]
|
|
1624
|
+
|
|
1625
|
+
\u26A0\uFE0F SPECIAL CONSIDERATIONS
|
|
1626
|
+
\u2022 [Any relevant weather warnings, UV index, wind conditions, etc.]
|
|
1627
|
+
|
|
1628
|
+
Guidelines:
|
|
1629
|
+
- Suggest 2-3 time-specific outdoor activities per day
|
|
1630
|
+
- Include 1-2 indoor backup options
|
|
1631
|
+
- For precipitation >50%, lead with indoor activities
|
|
1632
|
+
- All activities must be specific to the location
|
|
1633
|
+
- Include specific venues, trails, or locations
|
|
1634
|
+
- Consider activity intensity based on temperature
|
|
1635
|
+
- Keep descriptions concise but informative
|
|
1636
|
+
|
|
1637
|
+
Maintain this exact formatting for consistency, using the emoji and section headers as shown.
|
|
1638
|
+
\`,
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1590
1641
|
const forecastSchema = z.object({
|
|
1591
1642
|
date: z.string(),
|
|
1592
1643
|
maxTemp: z.number(),
|
|
@@ -1680,59 +1731,16 @@ const planActivities = createStep({
|
|
|
1680
1731
|
outputSchema: z.object({
|
|
1681
1732
|
activities: z.string(),
|
|
1682
1733
|
}),
|
|
1683
|
-
execute: async ({ inputData
|
|
1734
|
+
execute: async ({ inputData }) => {
|
|
1684
1735
|
const forecast = inputData
|
|
1685
1736
|
|
|
1686
1737
|
if (!forecast) {
|
|
1687
1738
|
throw new Error('Forecast data not found')
|
|
1688
1739
|
}
|
|
1689
1740
|
|
|
1690
|
-
const agent = mastra?.getAgent('weatherAgent');
|
|
1691
|
-
if (!agent) {
|
|
1692
|
-
throw new Error('Weather agent not found');
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
1741
|
const prompt = \`Based on the following weather forecast for \${forecast.location}, suggest appropriate activities:
|
|
1696
1742
|
\${JSON.stringify(forecast, null, 2)}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
\u{1F4C5} [Day, Month Date, Year]
|
|
1700
|
-
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
1701
|
-
|
|
1702
|
-
\u{1F321}\uFE0F WEATHER SUMMARY
|
|
1703
|
-
\u2022 Conditions: [brief description]
|
|
1704
|
-
\u2022 Temperature: [X\xB0C/Y\xB0F to A\xB0C/B\xB0F]
|
|
1705
|
-
\u2022 Precipitation: [X% chance]
|
|
1706
|
-
|
|
1707
|
-
\u{1F305} MORNING ACTIVITIES
|
|
1708
|
-
Outdoor:
|
|
1709
|
-
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1710
|
-
Best timing: [specific time range]
|
|
1711
|
-
Note: [relevant weather consideration]
|
|
1712
|
-
|
|
1713
|
-
\u{1F31E} AFTERNOON ACTIVITIES
|
|
1714
|
-
Outdoor:
|
|
1715
|
-
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1716
|
-
Best timing: [specific time range]
|
|
1717
|
-
Note: [relevant weather consideration]
|
|
1718
|
-
|
|
1719
|
-
\u{1F3E0} INDOOR ALTERNATIVES
|
|
1720
|
-
\u2022 [Activity Name] - [Brief description including specific venue]
|
|
1721
|
-
Ideal for: [weather condition that would trigger this alternative]
|
|
1722
|
-
|
|
1723
|
-
\u26A0\uFE0F SPECIAL CONSIDERATIONS
|
|
1724
|
-
\u2022 [Any relevant weather warnings, UV index, wind conditions, etc.]
|
|
1725
|
-
|
|
1726
|
-
Guidelines:
|
|
1727
|
-
- Suggest 2-3 time-specific outdoor activities per day
|
|
1728
|
-
- Include 1-2 indoor backup options
|
|
1729
|
-
- For precipitation >50%, lead with indoor activities
|
|
1730
|
-
- All activities must be specific to the location
|
|
1731
|
-
- Include specific venues, trails, or locations
|
|
1732
|
-
- Consider activity intensity based on temperature
|
|
1733
|
-
- Keep descriptions concise but informative
|
|
1734
|
-
|
|
1735
|
-
Maintain this exact formatting for consistency, using the emoji and section headers as shown.\`;
|
|
1743
|
+
\`;
|
|
1736
1744
|
|
|
1737
1745
|
const response = await agent.stream([
|
|
1738
1746
|
{
|
|
@@ -1787,7 +1795,7 @@ async function writeCodeSampleForComponents(llmprovider, component, destPath, im
|
|
|
1787
1795
|
case "tools":
|
|
1788
1796
|
return writeToolSample(destPath);
|
|
1789
1797
|
case "workflows":
|
|
1790
|
-
return writeWorkflowSample(destPath);
|
|
1798
|
+
return writeWorkflowSample(destPath, llmprovider);
|
|
1791
1799
|
default:
|
|
1792
1800
|
return "";
|
|
1793
1801
|
}
|