Skip to content

Commit

Permalink
Schedule Agent Fix (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
rounak610 committed Aug 11, 2023
1 parent d011aaf commit 0c77bf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions superagi/models/agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def update_agent_configurations_table(cls, session, agent_id: Union[int, None],
).first()

if agent_toolkits_config:
agent_toolkits_config.value = updated_details_dict['toolkits']
agent_toolkits_config.value = str(updated_details_dict['toolkits'])
else:
agent_toolkits_config = AgentConfiguration(
agent_id=agent_id,
key='toolkits',
value=updated_details_dict['toolkits']
value=str(updated_details_dict['toolkits'])
)
session.add(agent_toolkits_config)

Expand All @@ -67,25 +67,26 @@ def update_agent_configurations_table(cls, session, agent_id: Union[int, None],
).first()

if knowledge_config:
knowledge_config.value = updated_details_dict['knowledge']
knowledge_config.value = str(updated_details_dict['knowledge'])
else:
knowledge_config = AgentConfiguration(
agent_id=agent_id,
key='knowledge',
value=updated_details_dict['knowledge']
value=str(updated_details_dict['knowledge'])
)
session.add(knowledge_config)

# Fetch agent configurations
agent_configs = session.query(AgentConfiguration).filter(AgentConfiguration.agent_id == agent_id).all()
for agent_config in agent_configs:
if agent_config.key in updated_details_dict:
agent_config.value = updated_details_dict[agent_config.key]
agent_config.value = str(updated_details_dict[agent_config.key])

# Commit the changes to the database
session.commit()

return "Details updated successfully"

@classmethod
def get_model_api_key(cls, session, agent_id: int, model: str):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def test_update_existing_toolkits():
result = AgentConfiguration.update_agent_configurations_table(mock_session, agent_id, updated_details)

#Check whether the value gets updated or not
assert existing_toolkits_config.value == [1, 2]
assert existing_toolkits_config.value == '[1, 2]'
assert mock_session.commit.called_once()
assert result == "Details updated successfully"

0 comments on commit 0c77bf1

Please sign in to comment.