translation/translated/documents/course/01-first-agent/08-exporting-your-agent.md

35 lines
917 B
Markdown
Raw Permalink Normal View History

# 导出您的代理
为了让您的代理在 playground 中可用,您需要通过 `src/mastra/index.ts` 文件中的 Mastra 类导出它。
首先,导入必要的依赖项和您的代理:
```typescript
import { Mastra } from "@mastra/core";
import { PinoLogger } from "@mastra/loggers";
import { LibSQLStore } from "@mastra/libsql";
import { financialAgent } from "./agents/financial-agent";
export const mastra = new Mastra({
agents: {
financialAgent,
},
storage: new LibSQLStore({
id: "learning-memory-storage",
url: ":memory:",
}),
logger: new PinoLogger({
name: "Mastra",
level: "info",
}),
});
```
这将创建一个新的 Mastra 实例,包含:
- 您的金融代理
- 用于开发的内存存储
- 用于调试和监控的日志记录器
Mastra 类是您 Mastra 项目的主入口点。它负责注册您的代理并配置存储和日志记录等核心服务。