Skip to content

Commit 8d97a33

Browse files
committed
style(lint): 优化代码格式和错误处理
1 parent 558d268 commit 8d97a33

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

server/routers/chat_router.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ async def stream_messages():
581581
async for msg, metadata in agent.stream_messages(messages, input_context=input_context):
582582
if isinstance(msg, AIMessageChunk):
583583
full_msg = msg if not full_msg else full_msg + msg
584-
if conf.enable_content_guard and await content_guard.check_with_keywords(full_msg.content[-20:]):
584+
content_for_check = full_msg.content[-20:]
585+
if conf.enable_content_guard and await content_guard.check_with_keywords(content_for_check):
585586
logger.warning("Sensitive content detected in stream")
586587
await save_partial_message(conv_manager, thread_id, full_msg, "content_guard_blocked")
587588
meta["time_cost"] = asyncio.get_event_loop().time() - start_time
@@ -601,7 +602,8 @@ async def stream_messages():
601602
agent_state = _extract_agent_state(getattr(state, "values", {})) if state else {}
602603
if agent_state:
603604
yield make_chunk(status="agent_state", agent_state=agent_state, meta=meta)
604-
except Exception:
605+
except Exception as e:
606+
logger.error(f"Error processing tool message: {e}")
605607
pass
606608

607609
if (

src/knowledge/adapters/lightrag.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any
22

33
from src.utils import logger
4+
45
from .base import GraphAdapter
56

67

0 commit comments

Comments
 (0)