Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule Agent Fix #1043

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"