Commit 3f4781c0 by sunqi02 Committed by 胡悦

refactor: remove intent_session from ActiveSessionService

1 parent da4cfb6d
......@@ -65,16 +65,6 @@ class ActiveSessionService:
logger.exception("Failed to cold-recover session %s from DB, 降级新建", session_id)
db_sess = None
if db_sess:
intent_session_raw = (db_sess.intent_session or "").strip()
try:
intent_session = json.loads(intent_session_raw) if intent_session_raw else []
except (json.JSONDecodeError, TypeError, ValueError) as e:
logger.warning(
"session=%s intent_session 解析失败: %s, 降级为空",
session_id, e,
)
intent_session = []
payload = {
"session_id": db_sess.session_id,
"channel": db_sess.channel,
......@@ -82,7 +72,6 @@ class ActiveSessionService:
"conversation_history": json.loads(
db_sess.conversation_history or "[]"
),
"intent_session": intent_session,
"context_entities": {},
"created_at": (
db_sess.created_at.isoformat()
......@@ -104,7 +93,6 @@ class ActiveSessionService:
"channel": channel,
"room_id": room_id,
"conversation_history": [],
"intent_session": "",
"context_entities": {},
"created_at": _utcnow_iso(),
"updated_at": _utcnow_iso(),
......@@ -128,15 +116,9 @@ class ActiveSessionService:
return
history = data.get("conversation_history") or []
intent_session = data.get("intent_session", "")
intent_session_str = (
intent_session
if isinstance(intent_session, str)
else json.dumps(intent_session, ensure_ascii=False)
)
logger.info(
"[save_to_db] session=%s intent_session 长度=%d, conversation_history 长度=%d",
session_id, len(intent_session_str), len(history),
"[save_to_db] session=%s conversation_history 长度=%d",
session_id, len(history),
)
try:
......@@ -151,7 +133,6 @@ class ActiveSessionService:
existing.conversation_history = json.dumps(
data.get("conversation_history", []), ensure_ascii=False
)
existing.intent_session = intent_session_str
else:
db_sess = Session(
session_id=session_id,
......@@ -160,7 +141,6 @@ class ActiveSessionService:
conversation_history=json.dumps(
data.get("conversation_history", []), ensure_ascii=False
),
intent_session=intent_session_str,
)
db.add(db_sess)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!