From 37f1480b28993dbcd91c050941ffd16a80a30b90 Mon Sep 17 00:00:00 2001 From: suluyan Date: Wed, 8 Jan 2025 15:01:20 +0800 Subject: [PATCH] fix user_token --- apps/agentfabric/server.py | 4 ++-- apps/agentfabric/server_utils.py | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/agentfabric/server.py b/apps/agentfabric/server.py index e92871a4..a07ba868 100644 --- a/apps/agentfabric/server.py +++ b/apps/agentfabric/server.py @@ -125,7 +125,7 @@ def generate(): assert isinstance(exec_result, Config) builder_cfg = exec_result.to_dict() save_builder_configuration(builder_cfg, uuid_str) - app.session_manager.renew_user_bot(uuid_str) + app.session_manager.clear_user_bot(uuid_str) res = json.dumps( { 'data': response, @@ -353,7 +353,7 @@ def save_builder_config(uuid_str): error=str(e), details={'error_traceback': traceback.format_exc()}) save_builder_configuration(builder_cfg=builder_config, uuid_str=uuid_str) - app.session_manager.renew_user_bot(uuid_str) + app.session_manager.clear_user_bot(uuid_str) return jsonify({'success': True, 'request_id': request_id_var.get('')}) diff --git a/apps/agentfabric/server_utils.py b/apps/agentfabric/server_utils.py index c71e4094..d04b38e6 100644 --- a/apps/agentfabric/server_utils.py +++ b/apps/agentfabric/server_utils.py @@ -120,8 +120,6 @@ def get_builder_bot( builder_id, renew=False) -> Tuple[AgentBuilder, MemoryWithRetrievalKnowledge]: builder_agent = self.builder_bots[builder_id] - print(f'builder_id: {builder_id}') - print(f'builder_bots: {self.builder_bots.keys()}') if renew or builder_agent is None: logger.info(f'init_builder_chatbot_agent: {builder_id} ') builder_agent = init_builder_chatbot_agent(builder_id) @@ -141,10 +139,7 @@ def get_user_bot( session, user_token=None) -> Tuple[RolePlay, MemoryWithRetrievalKnowledge]: unique_id = builder_id + '_' + session - print(f'unique_id: {unique_id}') user_agent = self.user_bots[unique_id] - print(f'self.user_bots: {self.user_bots}') - print(f'user_agent: {user_agent}') if user_agent is None: logger.info(f'init_user_chatbot_agent: {builder_id} {session}') user_agent = init_user_chatbot_agent( @@ -164,9 +159,10 @@ def renew_user_bot( builder_id, session, use_tool_api=True, user_token=user_token) self.user_bots[unique_id] = user_agent - def clear_user_bot(self, builder_id, session): + def clear_user_bot(self, builder_id, session='default'): unique_id = builder_id + '_' + session user_agent = self.user_bots[unique_id] + logger.info(f'clear_user_chatbot_agent: {builder_id} {session}') if user_agent is not None: self.user_bots.delete_key(unique_id) shutil.rmtree(