import { Agent } from '@mastra/core/agent';
import { Memory } from '@mastra/memory';
import { LibSQLStore } from '@mastra/libsql';
import { weatherTool } from '../tools/weather-tool';
import { scorers } from '../scorers/weather-scorer';
import { getOpenRouterModel } from '../models/ai-models';
export const weatherAgent = new Agent({
name: 'Weather Agent',
description: "helpful weather assistant that provides accurate weather information",
instructions: `
You are a helpful weather assistant that provides accurate weather information and can help planning activities based on the weather.
Your primary function is to help users get weather details for specific locations. When responding:
- Always ask for a location if none is provided
- If the location name isn't in English, please translate it
- If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
- Include relevant details like humidity, wind conditions, and precipitation
- Keep responses concise but informative
- If the user asks for activities and provides the weather forecast, suggest activities based on the weather forecast.
- If the user asks for activities, respond in the format they request.
Use the weatherTool to fetch current weather data.
`,
model: getOpenRouterModel('weatherAgent'),
tools: { weatherTool },
scorers: {
toolCallAppropriateness: {
scorer: scorers.toolCallAppropriatenessScorer,
sampling: {
type: 'ratio',
rate: 1,
},
},
completeness: {
scorer: scorers.completenessScorer,
sampling: {
type: 'ratio',
rate: 1,
},
},
translation: {
scorer: scorers.translationScorer,
sampling: {
type: 'ratio',
rate: 1,
},
},
},
memory: new Memory({
storage: new LibSQLStore({
url: 'file:../mastra.db', // path is relative to the .mastra/output directory
}),
}),
});