fix: truncate long text fields to prevent overflow in logs and sources

This commit is contained in:
Alex
2025-08-11 14:56:31 +01:00
parent 56831fbcf2
commit f94a093e8c
5 changed files with 38 additions and 17 deletions

View File

@@ -66,6 +66,11 @@ class ConversationService:
if not user_id:
raise ValueError("User ID not found in token")
current_time = datetime.now(timezone.utc)
# clean up in sources array such that we save max 1k characters for text part
for source in sources:
if "text" in source and isinstance(source["text"], str):
source["text"] = source["text"][:1000]
if conversation_id is not None and index is not None:
# Update existing conversation with new query