🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-05-04 17:29:22 +00:00
parent 1da2b4ca70
commit 78e145bd56
4 changed files with 7 additions and 7 deletions

View File

@@ -1,15 +1,16 @@
from src.heart_flow.heartflow import heartflow
from src.heart_flow.sub_heartflow import ChatState
async def get_all_subheartflow_ids() -> list:
"""获取所有子心流的ID列表"""
all_subheartflows = heartflow.subheartflow_manager.get_all_subheartflows()
return [subheartflow.subheartflow_id for subheartflow in all_subheartflows]
async def forced_change_subheartflow_status(subheartflow_id: str, status: ChatState) -> bool:
"""强制改变子心流的状态"""
subheartflow = await heartflow.get_or_create_subheartflow(subheartflow_id)
if subheartflow:
return await heartflow.force_change_subheartflow_status(subheartflow_id, status)
return False

View File

@@ -27,13 +27,15 @@ router.include_router(graphql_router, prefix="/graphql", tags=["GraphQL"])
async def reload_config():
return await reload_config_func()
@router.get("/gui/subheartflow/get/all")
async def get_subheartflow_ids():
"""获取所有子心流的ID列表"""
return await get_all_subheartflow_ids()
@router.post("/gui/subheartflow/forced_change_status")
async def forced_change_subheartflow_status_api(subheartflow_id: str, status: ChatState): #noqa
async def forced_change_subheartflow_status_api(subheartflow_id: str, status: ChatState): # noqa
"""强制改变子心流的状态"""
# 参数检查
if not isinstance(status, ChatState):
@@ -49,7 +51,6 @@ async def forced_change_subheartflow_status_api(subheartflow_id: str, status: Ch
return {"status": "failed"}
def start_api_server():
"""启动API服务器"""
global_server.register_router(router, prefix="/api/v1")

View File

@@ -62,9 +62,7 @@ class Heartflow:
# 不再需要传入 self.current_state
return await self.subheartflow_manager.get_or_create_subheartflow(subheartflow_id)
async def force_change_subheartflow_status(
self, subheartflow_id: str, status: ChatState
) -> None:
async def force_change_subheartflow_status(self, subheartflow_id: str, status: ChatState) -> None:
"""强制改变子心流的状态"""
# 这里的 message 是可选的,可能是一个消息对象,也可能是其他类型的数据
return await self.subheartflow_manager.force_change_state(subheartflow_id, status)

View File

@@ -82,7 +82,7 @@ class SubHeartflowManager:
max_tokens=1000, # 与 Heartflow 一致 (虽然可能不需要这么多)
request_type="subheartflow_state_eval", # 保留特定的请求类型
)
async def force_change_state(self, subflow_id: Any, target_state: ChatState) -> bool:
"""强制改变指定子心流的状态"""
async with self._lock: