Skip to content

Commit 72972c3

Browse files
Hotfix empty logs (#163)
* fix: set default for missing time_elapsed * style: remove comment
1 parent c6f99a4 commit 72972c3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cognition_objects/message.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
from .pipeline_version import get_current_version
88

99

10+
DEFAULT_TIME_ELAPSED = {
11+
"time_elapsed": 0,
12+
"has_error": True,
13+
"answer": "",
14+
}
15+
16+
1017
def get_all_by_conversation_id(
1118
project_id: str, conversation_id: str
1219
) -> List[CognitionMessage]:
@@ -141,13 +148,15 @@ def get_message_short_for_conversation_for_pipeline(
141148
time_elapsed = general.execute_first(query)
142149
if time_elapsed and time_elapsed[0]:
143150
time_elapsed = time_elapsed[0]
151+
else:
152+
time_elapsed = {}
144153

145154
return [
146155
{
147156
"id": str(e.id),
148157
"question": e.question,
149158
"created_at": str(e.created_at),
150-
**time_elapsed.get(str(e.id), -1),
159+
**time_elapsed.get(str(e.id), DEFAULT_TIME_ELAPSED),
151160
}
152161
for e in (
153162
session.query(CognitionMessage)

0 commit comments

Comments
 (0)