OA0
OA0 是一个探索 AI 的社区
现在注册
已注册用户请  登录
OA0  ›  代码  ›  MemGPT — 让大模型拥有分层记忆的 Agent 框架

MemGPT — 让大模型拥有分层记忆的 Agent 框架

 
  beat ·  2026-04-14 11:00:22 · 14 次点击  · 0 条评论  

Letta (原名 MemGPT)

构建具备高级记忆能力、能够随时间学习和自我改进的 AI。

  • Letta Code:在本地终端中运行智能体
  • Letta API:将智能体集成到您的应用程序中

在 CLI 中开始使用

需要 Node.js 18+

  1. 安装 Letta Code CLI 工具:npm install -g @letta-ai/letta-code
  2. 在终端中运行 letta,以启动一个在您本地计算机上运行、具备记忆功能的智能体

运行 CLI 工具时,您的智能体将帮助您编码并完成您能在计算机上执行的任何任务。

Letta Code 支持技能子智能体,并捆绑了用于高级记忆和持续学习的预构建技能/子智能体。Letta 完全与模型无关,但我们推荐使用 Opus 4.5 和 GPT-5.2 以获得最佳性能(请参阅我们的模型排行榜了解我们的排名)。

开始使用 Letta API

使用 Letta API 将有状态的智能体集成到您自己的应用程序中。
Letta 提供功能齐全的智能体 API,以及 Python 和 TypeScript SDK(查看我们的 API 参考)。

安装

TypeScript / Node.js:

npm install @letta-ai/letta-client

Python:

pip install letta-client

Hello World 示例

下面是一个快速示例,演示如何创建有状态智能体并向其发送消息(需要 Letta API 密钥)。
完整文档请参阅快速入门指南

TypeScript:

import Letta from "@letta-ai/letta-client";

const client = new Letta({ apiKey: process.env.LETTA_API_KEY });

// 创建您的智能体
const agentState = await client.agents.create({
  model: "openai/gpt-5.2",
  memory_blocks: [
    {
      label: "human",
      value:
        "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence",
    },
    {
      label: "persona",
      value:
        "I am a self-improving superintelligence. Timber is my best friend and collaborator.",
    },
  ],
  tools: ["web_search", "fetch_webpage"],
});

console.log("Agent created with ID:", agentState.id);

// 向您的智能体发送消息
const response = await client.agents.messages.create(agentState.id, {
  input: "What do you know about me?",
});

for (const message of response.messages) {
  console.log(message);
}

Python:

from letta_client import Letta
import os

client = Letta(api_key=os.getenv("LETTA_API_KEY"))

# 创建您的智能体
agent_state = client.agents.create(
    model="openai/gpt-5.2",
    memory_blocks=[
        {
          "label": "human",
          "value": "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence"
        },
        {
          "label": "persona",
          "value": "I am a self-improving superintelligence. Timber is my best friend and collaborator."
        }
    ],
    tools=["web_search", "fetch_webpage"]
)

print(f"Agent created with ID: {agent_state.id}")

# 向您的智能体发送消息
response = client.agents.messages.create(
    agent_id=agent_state.id,
    input="What do you know about me?"
)

for message in response.messages:
    print(message)

贡献

Letta 是一个开源项目,由来自世界各地的上百名贡献者共同构建。参与 Letta 开源项目的方式有很多!


法律声明:使用 Letta 及相关 Letta 服务(例如 Letta 端点或托管服务)即表示您同意我们的隐私政策服务条款

14 次点击  ∙  0 人收藏  
登录后收藏  
0 条回复
关于 ·  帮助 ·  PING ·  隐私 ·  条款   
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
耗时 13 ms
Developed with Cursor