Skip to content

Commit 69f0043

Browse files
authored
fix: Application debugging will add new users (#3630)
1 parent f385bb3 commit 69f0043

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def event_content(response,
6565
message_list: List[BaseMessage],
6666
problem_text: str,
6767
padding_problem_text: str = None,
68-
client_id=None, client_type=None,
68+
chat_user_id=None, chat_user_type=None,
6969
is_ai_chat: bool = None,
7070
model_setting=None):
7171
if model_setting is None:
@@ -134,14 +134,16 @@ def event_content(response,
134134
request_token, response_token,
135135
{'node_is_end': True, 'view_type': 'many_view',
136136
'node_type': 'ai-chat-node'})
137-
add_access_num(client_id, client_type, manage.context.get('application_id'))
137+
if not manage.debug:
138+
add_access_num(chat_user_id, chat_user_type, manage.context.get('application_id'))
138139
except Exception as e:
139140
maxkb_logger.error(f'{str(e)}:{traceback.format_exc()}')
140141
all_text = 'Exception:' + str(e)
141142
write_context(step, manage, 0, 0, all_text)
142143
post_response_handler.handler(chat_id, chat_record_id, paragraph_list, problem_text,
143144
all_text, manage, step, padding_problem_text, reasoning_content='')
144-
add_access_num(client_id, client_type, manage.context.get('application_id'))
145+
if not manage.debug:
146+
add_access_num(chat_user_id, chat_user_type, manage.context.get('application_id'))
145147
yield manage.get_base_to_response().to_stream_chunk_response(chat_id, str(chat_record_id), 'ai-chat-node',
146148
[], all_text,
147149
False,
@@ -281,7 +283,7 @@ def execute_block(self, message_list: List[BaseMessage],
281283
paragraph_list=None,
282284
manage: PipelineManage = None,
283285
padding_problem_text: str = None,
284-
client_id=None, client_type=None, no_references_setting=None,
286+
chat_user_id=None, chat_user_type=None, no_references_setting=None,
285287
model_setting=None):
286288
reasoning_content_enable = model_setting.get('reasoning_content_enable', False)
287289
reasoning_content_start = model_setting.get('reasoning_content_start', '<think>')
@@ -311,7 +313,8 @@ def execute_block(self, message_list: List[BaseMessage],
311313
post_response_handler.handler(chat_id, chat_record_id, paragraph_list, problem_text,
312314
content, manage, self, padding_problem_text,
313315
reasoning_content=reasoning_content)
314-
add_access_num(client_id, client_type, manage.context.get('application_id'))
316+
if not manage.debug:
317+
add_access_num(chat_user_id, chat_user_type, manage.context.get('application_id'))
315318
return manage.get_base_to_response().to_block_response(str(chat_id), str(chat_record_id),
316319
content, True,
317320
request_token, response_token,
@@ -326,6 +329,7 @@ def execute_block(self, message_list: List[BaseMessage],
326329
write_context(self, manage, 0, 0, all_text)
327330
post_response_handler.handler(chat_id, chat_record_id, paragraph_list, problem_text,
328331
all_text, manage, self, padding_problem_text, reasoning_content='')
329-
add_access_num(client_id, client_type, manage.context.get('application_id'))
332+
if not manage.debug:
333+
add_access_num(chat_user_id, chat_user_type, manage.context.get('application_id'))
330334
return manage.get_base_to_response().to_block_response(str(chat_id), str(chat_record_id), all_text, True, 0,
331335
0, _status=status.HTTP_500_INTERNAL_SERVER_ERROR)

apps/application/flow/i_step_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def handler(self, workflow):
8383

8484
self.chat_info.append_chat_record(chat_record)
8585
self.chat_info.set_cache()
86-
if [ChatUserType.ANONYMOUS_USER.value, ChatUserType.CHAT_USER.value].__contains__(
86+
87+
if not self.chat_info.debug and [ChatUserType.ANONYMOUS_USER.value, ChatUserType.CHAT_USER.value].__contains__(
8788
workflow_body.get('chat_user_type')):
8889
application_public_access_client = (QuerySet(ApplicationChatUserStats)
8990
.filter(chat_user_id=workflow_body.get('chat_user_id'),

apps/application/serializers/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def import_(self, instance: dict, is_import_tool, with_valid=True):
533533
UserResourcePermissionSerializer(data={
534534
'workspace_id': self.data.get('workspace_id'),
535535
'user_id': self.data.get('user_id'),
536-
'auth_target_type': AuthTargetType.APPLICATION.value
536+
'auth_target_type': AuthTargetType.TOOL.value
537537
}).auth_resource_batch([t.id for t in tool_model_list])
538538
return True
539539

0 commit comments

Comments
 (0)