Skip to content

fix: Missing fields in exported logs #2817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/application/serializers/chat_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def to_row(row: Dict):
"\n".join([
f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}"
for index in range(len(improve_paragraph_list))]),
row.get('asker').get('user_name'),
row.get('message_tokens') + row.get('answer_tokens'), row.get('run_time'),
str(row.get('create_time').astimezone(pytz.timezone(TIME_ZONE)).strftime('%Y-%m-%d %H:%M:%S')
)]
Expand All @@ -242,7 +243,8 @@ def stream_response():
gettext('answer'), gettext('User feedback'),
gettext('Reference segment number'),
gettext('Section title + content'),
gettext('Annotation'), gettext('Consuming tokens'), gettext('Time consumed (s)'),
gettext('Annotation'), gettext('USER'), gettext('Consuming tokens'),
gettext('Time consumed (s)'),
gettext('Question Time')]
for col_idx, header in enumerate(headers, 1):
cell = worksheet.cell(row=1, column=col_idx)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of issues in the provided code:

  1. Potential Typographical Error: The string 'USER' is not quoted in workbook.update_cells(), which might lead to an issue if you intend it to be treated as a cell value rather than just plain text.

  2. Missing Line Breaks in Headers: There's no line break added after "ANNOTATION" and before the next label ("CONSUMING TOKENS"). This can make the headers harder to read on some systems.

  3. Inconsistent Header Formatting: Some labels use commas instead of spaces to separate words, while others do not. It would be consistent if we used a single convention across all header entries.

Here’s an improved version of the code with these considerations addressed:

@@ -215,6 +215,7 @@ def to_row(row: Dict):
                        f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}"
                         for index in range(len(improve_paragraph_list))]),
+                    row.get('asker').get('user_name'),
                     row.get('message_tokens') + row.get('answer_tokens'), row.get('run_time'),
                     str(row.get('create_time').astimezone(pytz.timezone(TIME_ZONE)).strftime('%Y-%m-%d %H:%M:%S'))
                )
                 workbook.update_cells([(row_index + 2, col_idx) for col_idx, _ in enumerate(headers)], values=row_data)

@@ -242,8 +242,9 @@ def stream_response():
                                gettext('answer'), gettext('User feedback'),
                                gettext('Reference segment number'),
                                gettext('Section title + content'),
-                               gettext('Annotation'), gettext('Consuming tokens'), gettext('Time consumed (s)'),
+                               gettext('Annotation'), gettext('USER'), gettext('Consuming tokens'),
+                               gettext('TIME CONSUMED (S)'), # Consistent header formatting
                                gettext('Question Time')]
                         for col_idx, header in enumerate(headers, 1):
                             cell = worksheet.cell(row=1, column=col_idx)

These changes should improve readability and consistency in your spreadsheet output.

Expand Down
3 changes: 2 additions & 1 deletion apps/application/sql/export_application_chat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ SELECT
application_chat_record_temp."index" as "index",
application_chat_record_temp.improve_paragraph_list as improve_paragraph_list,
application_chat_record_temp.vote_status as vote_status,
application_chat_record_temp.create_time as create_time
application_chat_record_temp.create_time as create_time,
to_json(application_chat.asker) as asker
FROM
application_chat application_chat
LEFT JOIN (
Expand Down