Skip to content

[Bug] 大模型输出入库前,建议加一个数据校验 #4511

@Msswill

Description

@Msswill

Contact Information

No response

MaxKB Version

2.4.0

Problem Description

Traceback (most recent call last): File "/usr/local/lib/python3.11/wsgiref/handlers.py", line 138, in run self.finish_response() File "/opt/py3/lib/python3.11/site-packages/django/core/servers/basehttp.py", line 174, in finish_response super().finish_response() File "/usr/local/lib/python3.11/wsgiref/handlers.py", line 183, in finish_response for data in self.result: File "/opt/maxkb-app/apps/application/flow/workflow_manage.py", line 341, in await_result self.work_flow_post_handler.handler(self) File "/opt/maxkb-app/apps/application/flow/i_step_node.py", line 86, in handler self.chat_info.append_chat_record(chat_record) File "/opt/maxkb-app/apps/application/serializers/common.py", line 227, in append_chat_record QuerySet(ChatRecord).update_or_create(id=chat_record.id, File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 990, in update_or_create obj, created = self.select_for_update().get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 955, in get_or_create return self.create(**params), True ^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 665, in create obj.save(force_insert=True, using=self.db) File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 902, in save self.save_base( File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 1008, in save_base updated = self._save_table( ^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 1169, in _save_table results = self._do_insert( ^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 1210, in _do_insert return manager._insert( ^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 1873, in _insert return query.get_compiler(using=using).execute_sql(returning_fields) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql cursor.execute(sql, params) File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute return self._execute_with_wrappers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers return executor(sql, params, many, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute with self.db.wrap_database_errors: File "/opt/py3/lib/python3.11/site-packages/django/db/utils.py", line 91, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/psycopg/cursor.py", line 97, in execute raise ex.with_traceback(None) django.db.utils.DataError: unsupported Unicode escape sequence LINE 19: ...77dd4\"}]"}'::jsonb[]::jsonb[], 40559, 1071, 0, E'{"e5c2c2... ^ DETAIL: \u0000 cannot be converted to text. CONTEXT: JSON data, line 1: ...240\u793a\u3002\n\u72b6\u6001\u66f4\u65b0\n\u0000...

Steps to Reproduce

Traceback (most recent call last): File "/usr/local/lib/python3.11/wsgiref/handlers.py", line 138, in run self.finish_response() File "/opt/py3/lib/python3.11/site-packages/django/core/servers/basehttp.py", line 174, in finish_response super().finish_response() File "/usr/local/lib/python3.11/wsgiref/handlers.py", line 183, in finish_response for data in self.result: File "/opt/maxkb-app/apps/application/flow/workflow_manage.py", line 341, in await_result self.work_flow_post_handler.handler(self) File "/opt/maxkb-app/apps/application/flow/i_step_node.py", line 86, in handler self.chat_info.append_chat_record(chat_record) File "/opt/maxkb-app/apps/application/serializers/common.py", line 227, in append_chat_record QuerySet(ChatRecord).update_or_create(id=chat_record.id, File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 990, in update_or_create obj, created = self.select_for_update().get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 955, in get_or_create return self.create(**params), True ^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 665, in create obj.save(force_insert=True, using=self.db) File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 902, in save self.save_base( File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 1008, in save_base updated = self._save_table( ^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 1169, in _save_table results = self._do_insert( ^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/base.py", line 1210, in _do_insert return manager._insert( ^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 1873, in _insert return query.get_compiler(using=using).execute_sql(returning_fields) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql cursor.execute(sql, params) File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute return self._execute_with_wrappers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers return executor(sql, params, many, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute with self.db.wrap_database_errors: File "/opt/py3/lib/python3.11/site-packages/django/db/utils.py", line 91, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/py3/lib/python3.11/site-packages/psycopg/cursor.py", line 97, in execute raise ex.with_traceback(None) django.db.utils.DataError: unsupported Unicode escape sequence LINE 19: ...77dd4\"}]"}'::jsonb[]::jsonb[], 40559, 1071, 0, E'{"e5c2c2... ^ DETAIL: \u0000 cannot be converted to text. CONTEXT: JSON data, line 1: ...240\u793a\u3002\n\u72b6\u6001\u66f4\u65b0\n\u0000...

The expected correct result

No response

Related log output

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions