Hide admin memory details and fix memory config
This commit is contained in:
+15
-36
@@ -522,7 +522,7 @@ class AgentState:
|
||||
)
|
||||
self.memory_manager = PersonalMemoryManager(
|
||||
self.session_directory.parent / 'accounts',
|
||||
self.config_for,
|
||||
self.model_config_for,
|
||||
)
|
||||
self.memory_manager.start()
|
||||
|
||||
@@ -571,6 +571,20 @@ class AgentState:
|
||||
with self._lock:
|
||||
return self._config_for(account_id)
|
||||
|
||||
def model_config_for(self, account_id: str | None) -> ModelConfig:
|
||||
"""给后台辅助任务使用的模型配置。
|
||||
|
||||
AgentInstanceConfig 还包含 cwd、权限等运行态字段;调用模型时需要的是
|
||||
OpenAICompatClient 支持的 ModelConfig,否则后台记忆整理会缺少 temperature 等字段。
|
||||
"""
|
||||
config = self.config_for(account_id)
|
||||
return ModelConfig(
|
||||
model=config.model,
|
||||
base_url=config.base_url,
|
||||
api_key=config.api_key,
|
||||
timeout_seconds=config.timeout_seconds,
|
||||
)
|
||||
|
||||
def _set_config_for(self, account_id: str | None, config: AgentInstanceConfig) -> None:
|
||||
if not account_id:
|
||||
self._default_config = config
|
||||
@@ -980,7 +994,6 @@ class AdminAccountCreateRequest(BaseModel):
|
||||
class MemoryUpdateRequest(BaseModel):
|
||||
account_id: str = Field(min_length=1)
|
||||
content: str
|
||||
skill: str | None = None
|
||||
|
||||
|
||||
def _append_runtime_context(current: str | None, addition: str) -> str:
|
||||
@@ -1309,40 +1322,6 @@ def create_app(state: AgentState) -> FastAPI:
|
||||
),
|
||||
}
|
||||
|
||||
@app.get('/api/admin/memory/user')
|
||||
async def admin_user_memory(token: str, account_id: str) -> dict[str, Any]:
|
||||
_require_admin_token(token)
|
||||
return state.memory_manager.list_user_memory(_safe_account_id(account_id))
|
||||
|
||||
@app.put('/api/admin/memory/user')
|
||||
async def admin_update_user_memory(
|
||||
token: str,
|
||||
payload: MemoryUpdateRequest,
|
||||
) -> dict[str, Any]:
|
||||
_require_admin_token(token)
|
||||
return state.memory_manager.update_user_memory(
|
||||
_safe_account_id(payload.account_id),
|
||||
payload.content,
|
||||
)
|
||||
|
||||
@app.get('/api/admin/memory/skills')
|
||||
async def admin_skill_memories(token: str, account_id: str) -> list[dict[str, Any]]:
|
||||
_require_admin_token(token)
|
||||
return state.memory_manager.list_skill_memories(_safe_account_id(account_id))
|
||||
|
||||
@app.put('/api/admin/memory/skills/{skill_name}')
|
||||
async def admin_update_skill_memory(
|
||||
skill_name: str,
|
||||
token: str,
|
||||
payload: MemoryUpdateRequest,
|
||||
) -> dict[str, Any]:
|
||||
_require_admin_token(token)
|
||||
return state.memory_manager.update_skill_memory(
|
||||
_safe_account_id(payload.account_id),
|
||||
skill_name,
|
||||
payload.content,
|
||||
)
|
||||
|
||||
@app.get('/api/models')
|
||||
async def list_models_get(account_id: str | None = None) -> dict[str, Any]:
|
||||
config = state.config_for(account_id)
|
||||
|
||||
Reference in New Issue
Block a user