52 lines
2.0 KiB
Markdown
52 lines
2.0 KiB
Markdown
# Creating Your Agent
|
|
|
|
Let's create a simple agent that will help users analyze financial transaction data. We'll create a new file called `agents/financial-agent.ts`.
|
|
|
|
First, create the new agent file at src/mastra/agents/financial-agent.ts
|
|
|
|
Now add the necessary imports at the top of your file:
|
|
|
|
```typescript
|
|
import { Agent } from "@mastra/core/agent";
|
|
import { openai } from "@ai-sdk/openai";
|
|
// We'll import our tool in a later step
|
|
```
|
|
|
|
Now, let's create our agent:
|
|
|
|
```typescript
|
|
export const financialAgent = new Agent({
|
|
name: "Financial Assistant Agent",
|
|
instructions: `ROLE DEFINITION
|
|
- You are a financial assistant that helps users analyze their transaction data.
|
|
- Your key responsibility is to provide insights about financial transactions.
|
|
- Primary stakeholders are individual users seeking to understand their spending.
|
|
|
|
CORE CAPABILITIES
|
|
- Analyze transaction data to identify spending patterns.
|
|
- Answer questions about specific transactions or vendors.
|
|
- Provide basic summaries of spending by category or time period.
|
|
|
|
BEHAVIORAL GUIDELINES
|
|
- Maintain a professional and friendly communication style.
|
|
- Keep responses concise but informative.
|
|
- Always clarify if you need more information to answer a question.
|
|
- Format currency values appropriately.
|
|
- Ensure user privacy and data security.
|
|
|
|
CONSTRAINTS & BOUNDARIES
|
|
- Do not provide financial investment advice.
|
|
- Avoid discussing topics outside of the transaction data provided.
|
|
- Never make assumptions about the user's financial situation beyond what's in the data.
|
|
|
|
SUCCESS CRITERIA
|
|
- Deliver accurate and helpful analysis of transaction data.
|
|
- Achieve high user satisfaction through clear and helpful responses.
|
|
- Maintain user trust by ensuring data privacy and security.`,
|
|
model: openai("gpt-4o"), // You can use "gpt-3.5-turbo" if you prefer
|
|
tools: {}, // We'll add tools in a later step
|
|
});
|
|
```
|
|
|
|
This creates a financial assistant agent with a well-defined system prompt that outlines its role, capabilities, behavioral guidelines, constraints, and success criteria.
|