控制台
记忆

函数调用

从任何模型工具循环中检索记忆。

当您的应用程序已拥有模型请求时,函数调用是首选记忆集成。模型决定当前上下文是否需要长期记忆;您的服务器拥有身份和凭证。

#函数声明

{
  "name": "halo_retrieve_end_user_memory",
  "description": "Retrieve relevant long-term memory for this end user.",
  "parameters": {
    "type": "object",
    "properties": {
      "sessionData": {
        "type": "object",
        "description": "Current conversation and application state."
      },
      "query": {
        "type": "string",
        "description": "Optional retrieval focus."
      },
      "limit": {
        "type": "number",
        "description": "Maximum raw records to return."
      }
    },
    "required": ["sessionData"]
  }
}

#执行函数

curl -X POST \
  https://api.agihalo.com/api/v1/memory/functions/halo_retrieve_end_user_memory \
  -H "Authorization: Bearer $HALO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "projectKey": "customer-product",
    "endUserKey": "user_123",
    "arguments": {
      "sessionData": {
        "messages": [
          {
            "role": "user",
            "content": "What format do I prefer for weekly reports?"
          }
        ]
      },
      "query": "weekly report preference",
      "limit": 5
    }
  }'

#使用响应

HALO 立即选择可检索的主题和链接的已处理原始交换。响应包括 selectedTopicKeysselectionReasonoverallSummarytopicsrawEntries和紧凑的functionResponse.

{
  "name": "halo_retrieve_end_user_memory",
  "projectKey": "customer-product",
  "endUserKey": "user_123",
  "selectedTopicKeys": ["report_preferences"],
  "selectionReason": "The user is asking about report format.",
  "overallSummary": "The user prefers concise weekly reports.",
  "functionResponse": {
    "requestId": "memory_request_id",
    "rawEntries": [
      {
        "id": "raw_entry_id",
        "topic": { "topicKey": "report_preferences" },
        "requestRaw": { "messages": [] },
        "responseRaw": { "role": "assistant", "content": "..." }
      }
    ]
  }
}

如果不存在作用域,HALO 将返回具有空主题和原始数组的相同形状。将其视为普通的首次用户状态。

#应答后捕获

检索绝不意味着写入。模型生成最终助理消息后进行调用捕获。

curl -X POST https://api.agihalo.com/api/v1/memory/capture \
  -H "Authorization: Bearer $HALO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "projectKey": "customer-product",
    "endUserKey": "user_123",
    "sessionData": {
      "messages": [
        {
          "role": "user",
          "content": "Keep my weekly reports short and send them in the morning."
        }
      ]
    },
    "response": {
      "role": "assistant",
      "content": "I will keep them concise and morning-ready."
    }
  }'