feat:优化了auto切换聊天模式机制,修改取名prompt,不再处理temp

This commit is contained in:
SengokuCola
2025-05-27 21:45:03 +08:00
parent 7e59382603
commit 369de9d137
14 changed files with 237 additions and 70 deletions

View File

@@ -1,6 +1,7 @@
from src.chat.heart_flow.heartflow import heartflow
from src.chat.heart_flow.sub_heartflow import ChatState
from src.common.logger_manager import get_logger
import time
logger = get_logger("api")
@@ -30,6 +31,29 @@ async def get_subheartflow_cycle_info(subheartflow_id: str, history_len: int) ->
return None
async def get_normal_chat_replies(subheartflow_id: str, limit: int = 10) -> list:
"""获取子心流的NormalChat回复记录
Args:
subheartflow_id: 子心流ID
limit: 最大返回数量默认10条
Returns:
list: 回复记录列表,如果未找到则返回空列表
"""
replies = await heartflow.api_get_normal_chat_replies(subheartflow_id, limit)
logger.debug(f"子心流 {subheartflow_id} NormalChat回复记录: 获取到 {len(replies) if replies else 0}")
if replies:
# 格式化时间戳为可读时间
for reply in replies:
if "time" in reply:
reply["formatted_time"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(reply["time"]))
return replies
else:
logger.warning(f"子心流 {subheartflow_id} NormalChat回复记录未找到")
return []
async def get_all_states():
"""获取所有状态"""
all_states = await heartflow.api_get_all_states()