diff --git a/superagi/models/agent_config.py b/superagi/models/agent_config.py index f7af6de01..640b922e0 100644 --- a/superagi/models/agent_config.py +++ b/superagi/models/agent_config.py @@ -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) @@ -67,12 +67,12 @@ 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) @@ -80,12 +80,13 @@ def update_agent_configurations_table(cls, session, agent_id: Union[int, None], 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): """ diff --git a/tests/unit_tests/controllers/test_update_agent_config_table.py b/tests/unit_tests/controllers/test_update_agent_config_table.py index 53297e7ad..632f59083 100644 --- a/tests/unit_tests/controllers/test_update_agent_config_table.py +++ b/tests/unit_tests/controllers/test_update_agent_config_table.py @@ -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"