news 2026/9/13 2:37:32

User Information

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
User Information

User Information

【免费下载链接】mastraMastra is the modern TypeScript framework for AI-powered applications and agents.项目地址: https://gitcode.com/GitHub_Trending/ma/mastra

  • First Name:
  • Last Name:
  • Location:
  • Occupation:
  • Interests:
  • Goals:
  • Events:
  • Facts:
  • Projects:
### 自定义工作记忆模板 模板引导 Agent 跟踪与更新哪些信息。虽然不提供模板时系统会使用默认模板,但通常你会为特定用例定义自定义模板(详见 [22-custom-working-memory-templates.md](https://link.gitcode.com/i/e384a3d1914ee1892a4890e69e33de0f)): ```typescript options: { semanticRecall: { topK: 3, messageRange: { before: 2, after: 1 }, }, workingMemory: { enabled: true, template: ` # User Profile ## Personal Info - Name: - Location: - Timezone: ## Preferences - Communication Style: [e.g., Formal, Casual] - Interests: - Favorite Topics: ## Session State - Current Topic: - Open Questions: - [Question 1] - [Question 2] `, }, }

模板是一份定义工作记忆结构的 Markdown 文档,包含个人信息、偏好、会话状态等不同类型的章节。它的作用有三:

  1. 引导 Agent 该跟踪哪些信息、如何组织;
  2. 为跨会话的工作记忆提供一致的结构;
  3. 让 Agent 更容易定位和更新特定信息片段。

在源码的 getWorkingMemoryTemplate() 中,模板支持两种格式:Markdown(字符串模板)或JSON(当配置了schema时,会把 Zod/JSON Schema 转换为 JSON Schema draft-07 交给模型)。设计模板时应基于 Agent 的具体需求以及它需要记住的关于用户或任务的信息类型。

综合实战:构建完整的记忆增强 Agent

现在把三大特性整合到一个 Agent 中(详见 25-combining-memory-features.md):

// src/mastra/agents/memory-agent.ts import { Agent } from '@mastra/core/agent' import { Memory } from '@mastra/memory' import { LibSQLStore, LibSQLVector } from '@mastra/libsql' // 创建综合记忆配置 const memory = new Memory({ storage: new LibSQLStore({ id: 'learning-memory-storage', url: 'file:../../memory.db', // 相对 .mastra/output 目录的路径 }), vector: new LibSQLVector({ url: 'file:../../vector.db', // 相对 .mastra/output 目录的路径 }), embedder: 'openai/text-embedding-3-small', options: { // 会话历史配置 lastMessages: 20, // 上下文包含最近 20 条消息 // 语义召回配置 semanticRecall: { topK: 3, // 召回 3 条最相似消息 messageRange: { before: 2, // 每条命中前附带 2 条 after: 1, // 每条命中后附带 1 条 }, }, // 工作记忆配置 workingMemory: { enabled: true, template: ` # User Profile ## Personal Info - Name: - Location: - Timezone: - Occupation: ## Preferences - Communication Style: - Topics of Interest: - Learning Goals: ## Project Information - Current Projects: - [Project 1]: - Deadline: - Status: - [Project 2]: - Deadline: - Status: ## Session State - Current Topic: - Open Questions: - Action Items: `, }, }, })

【免费下载链接】mastraMastra is the modern TypeScript framework for AI-powered applications and agents.项目地址: https://gitcode.com/GitHub_Trending/ma/mastra

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/13 2:36:24

CANN Runtime日志分级过滤机制与排障实践:从源码到落盘

CANN Runtime日志系统集成:日志分级过滤输出的实现与源码拆解先说一个我自己调试NPU任务时的典型场景。你写了一个基于CANN的推理程序,在Atlas训练卡上跑起来,结果第一条aclrtLaunch就返回了错误码。这时候大多数人会先怀疑算法写错了&#x…

作者头像 李华
网站建设 2026/9/13 2:34:04

小米14存储魔改原理:UFS重映射释放8GB空间

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/9/13 2:33:41

Ubuntu 22.04源码安装Bochs:打造x86模拟调试环境

写这篇东西其实挺感慨的。我最早接触 Bochs 还是在大学做操作系统课程实验的时候,那时候为了调试一个 bootloader,在 Windows 上用 Bochs 折腾了一整晚。后来转到 Linux 平台,发现 Ubuntu 上虽然能用 apt 直接装一个 bochs,但只要…

作者头像 李华