AgentStorage 是知識儲存和記憶儲存的執行個體級資源容器。建立知識庫或記憶庫之前,必須先在目標地區建立 AgentStorage;後續 SDK 和資料面 API 使用該執行個體的名稱與 HTTPS Endpoint 定位資源。
資源層級
阿里雲帳號
└── 地區
└── AgentStorage 執行個體
├── 知識庫
│ ├── 文檔
│ └── 切片與索引
└── 記憶庫
├── 長期記憶、短期訊息和任務
├── 檔案、檔案版本和 Dream
└── Agent Wiki(知識圖譜)與頁面知識庫名稱和記憶庫名稱在所屬 AgentStorage 執行個體內管理。執行個體決定這些資源使用的地區、訪問入口、網路邊界和執行個體級存取控制策略。
管理面與資料面
層面 | 管理對象 | 調用入口 | 認證 |
管理面 | AgentStorage 執行個體、VPC 綁定、執行個體存取控制策略 |
| AccessKey 簽名 |
資料面 | 知識庫、記憶庫及其子資源 | AgentStorage HTTPS Endpoint | API Key 或 AccessKey |
管理面欄位使用 PascalCase,例如 AgentStorageName;知識和記憶資料面主要使用 camelCase,例如 knowledgeBaseName 和 memoryStoreName。
建立執行個體
建立時至少指定 AgentStorageName。可以同時指定描述、資源群組、標籤、允許的網路類型以及存取控制策略。
推薦流程:
在目標地區調用建立 AgentStorage。
使用列出 AgentStorage查詢狀態。
等待
AgentStorageStatus變為normal。擷取執行個體的訪問地址(endpoint),並在 SDK 中把 AgentStorage 名稱配置為執行個體名稱。
控制台
登入 AgentStorage 控制台,在頂部地區下拉框中選擇目標地區。當前支援華北 2(北京)、華東 1(杭州)、華東 2(上海)、華南 1(深圳)、中國香港和新加坡,資源不跨地區顯示。
在左側導覽列單擊 AgentStorage 管理,然後在頁面右上方單擊 建立 AgentStorage。
在建立 AgentStorage 對話方塊中填寫以下參數,然後單擊確定。
參數
說明
名稱
必填。長度為 3~16 個字元,以英文字母開頭,只能包含英文字母、數字和短劃線,末尾不能是短劃線;同一地區內名稱不能重複。
描述
可選。說明該執行個體的業務情境,最多 128 個字元。
資源群組
可選。用於統一管理資源和許可權。
建立後執行個體顯示在 AgentStorage 管理 列表中。等待狀態列變為可用,即表示執行個體已就緒。
單擊執行個體名稱或操作列的詳情,查看並複製執行個體的訪問地址(Endpoint),用於在 SDK 和資料面 API 中定位執行個體;單擊操作列的進入 AgentStorage,可進入執行個體管理知識庫和記憶庫。
SDK
執行個體管理屬於管控面 OpenAPI(Tablestore/2020-12-09),使用 AccessKey 簽名。以下樣本使用 Python 管控面 SDK alibabacloud_tablestore20201209 建立執行個體並等待其就緒。
import os
import time
from alibabacloud_tablestore20201209.client import Client
from alibabacloud_tablestore20201209 import models as tablestore_models
from alibabacloud_tea_openapi import models as open_api_models
# 使用管控面 AccessKey 初始化用戶端,endpoint 由 region_id 自動解析(如 tablestore.cn-hangzhou.aliyuncs.com)
config = open_api_models.Config(
access_key_id=os.environ["ALIBABA_CLOUD_ACCESS_KEY_ID"],
access_key_secret=os.environ["ALIBABA_CLOUD_ACCESS_KEY_SECRET"],
region_id="cn-hangzhou",
)
client = Client(config)
# 1. 建立 AgentStorage 執行個體
client.create_agent_storage(
tablestore_models.CreateAgentStorageRequest(
agent_storage_name="agent-prod",
agent_storage_description="AI Agent 的知識與記憶儲存",
)
)
# 2. 輪詢執行個體狀態,直到 AgentStorageStatus 變為 normal
get_request = tablestore_models.GetAgentStorageRequest(agent_storage_name="agent-prod")
while client.get_agent_storage(get_request).body.agent_storage_status != "normal":
time.sleep(2)
print("AgentStorage 已就緒,可建立知識庫和記憶庫")刪除執行個體
控制台
登入 AgentStorage 控制台,在頂部選擇執行個體所在地區,然後在左側導覽列單擊 AgentStorage 管理。
在目標執行個體所在行的操作列,單擊更多,然後單擊刪除。
在確認刪除 AgentStorage 對話方塊中核對執行個體名稱,確認無誤後單擊確認刪除。刪除操作不可恢複。
SDK
刪除同樣通過管控面 SDK alibabacloud_tablestore20201209 調用 DeleteAgentStorage。
import os
from alibabacloud_tablestore20201209.client import Client
from alibabacloud_tablestore20201209 import models as tablestore_models
from alibabacloud_tea_openapi import models as open_api_models
config = open_api_models.Config(
access_key_id=os.environ["ALIBABA_CLOUD_ACCESS_KEY_ID"],
access_key_secret=os.environ["ALIBABA_CLOUD_ACCESS_KEY_SECRET"],
region_id="cn-hangzhou",
)
client = Client(config)
# 刪除 AgentStorage 執行個體;刪除後執行個體內的表、表資料和相關索引不可恢複
client.delete_agent_storage(
tablestore_models.DeleteAgentStorageRequest(agent_storage_name="agent-test")
)停止向執行個體內的知識庫和記憶庫寫入資料。
確認依賴該執行個體訪問地址、API Key 和 VPC 地址的應用已經遷移。
匯出或備份仍需保留的資料。
刪除後不要立即建立同名 AgentStorage,以免與後台釋放過程衝突。
刪除操作不可恢複,並會導致執行個體中的表、表資料和相關索引不可用。
使用限制
單個阿里雲帳號最多建立 10 個 AgentStorage 執行個體。
AgentStorage 名稱在同一地區內唯一,長度為 3~16 個字元。
名稱必須以英文字母開頭,只能包含英文字母、數字和短劃線,末尾不能是短劃線。
名稱大小寫不敏感,並且不能包含
ali、ay、ots、taobao或admin。