Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
suluyana committed Jan 3, 2025
1 parent a206624 commit 141461b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/agentfabric/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.clear_user_bot(uuid_str)
app.session_manager.renew_user_bot(uuid_str)

return jsonify({'success': True, 'request_id': request_id_var.get('')})

Expand Down
20 changes: 18 additions & 2 deletions apps/agentfabric/server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ 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)
Expand All @@ -137,17 +139,31 @@ def get_user_bot(
self,
builder_id,
session,
renew=False,
user_token=None) -> Tuple[RolePlay, MemoryWithRetrievalKnowledge]:
unique_id = builder_id + '_' + session
print(f'unique_id: {unique_id}')
user_agent = self.user_bots[unique_id]
if renew or user_agent is None:
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(
builder_id, session, use_tool_api=True, user_token=user_token)
self.user_bots[unique_id] = user_agent
return user_agent

def renew_user_bot(
self,
builder_id,
session='default',
user_token=None):
self.clear_user_bot(builder_id, session)
unique_id = builder_id + '_' + session
logger.info(f'reinit_user_chatbot_agent: {builder_id} {session}')
user_agent = init_user_chatbot_agent(
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):
unique_id = builder_id + '_' + session
user_agent = self.user_bots[unique_id]
Expand Down
5 changes: 5 additions & 0 deletions apps/agentfabric/user_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def init_user_chatbot_agent(uuid_str='',
user_token=user_token,
openapi_list=openapi_plugin_list)

logger.query_info(
uuid=uuid_str,
message=
f'init {builder_cfg.name} chatbot end.')

# build memory
preview_history_dir = get_user_preview_history_dir(uuid_str, session)
storage_path = preview_history_dir
Expand Down

0 comments on commit 141461b

Please sign in to comment.