Merge branch 'main' into feat/agent-menu

This commit is contained in:
Siddhant Rai
2025-04-16 18:35:38 +05:30
21 changed files with 1568 additions and 231 deletions

View File

@@ -657,6 +657,7 @@ class Answer(Resource):
source_log_docs = []
tool_calls = []
stream_ended = False
thought = ""
for line in complete_stream(
question=question,
@@ -679,6 +680,8 @@ class Answer(Resource):
source_log_docs = event["source"]
elif event["type"] == "tool_calls":
tool_calls = event["tool_calls"]
elif event["type"] == "thought":
thought = event["thought"]
elif event["type"] == "error":
logger.error(f"Error from stream: {event['error']}")
return bad_request(500, event["error"])
@@ -710,6 +713,7 @@ class Answer(Resource):
conversation_id,
question,
response_full,
thought,
source_log_docs,
tool_calls,
llm,
@@ -876,14 +880,7 @@ def get_attachments_content(attachment_ids, user):
)
if attachment_doc:
attachments.append(
{
"id": str(attachment_doc["_id"]),
"content": attachment_doc["content"],
"token_count": attachment_doc.get("token_count", 0),
"path": attachment_doc.get("path", ""),
}
)
attachments.append(attachment_doc)
except Exception as e:
logger.error(f"Error retrieving attachment {attachment_id}: {e}")