Skip to content

Commit

Permalink
Toolmarketplace (#1098)
Browse files Browse the repository at this point in the history
* fixed toolconfig update when installed from marketplace

* toolconfig and toolkit test fix
  • Loading branch information
sayan1101 committed Aug 22, 2023
1 parent ccc108f commit c990e16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions superagi/controllers/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def install_toolkit_from_marketplace(toolkit_name: str,
folder_name=tool['folder_name'], class_name=tool['class_name'], file_name=tool['file_name'],
toolkit_id=db_toolkit.id)
for config in toolkit['configs']:
ToolConfig.add_or_update(session=db.session, toolkit_id=db_toolkit.id, key=config['key'], value=config['value'])
ToolConfig.add_or_update(session=db.session, toolkit_id=db_toolkit.id, key=config['key'], value=config['value'], key_type = config['key_type'], is_secret = config['is_secret'], is_required = config['is_required'])
return {"message": "ToolKit installed successfully"}


Expand Down Expand Up @@ -364,4 +364,4 @@ def update_toolkit(toolkit_name: str, organisation: Organisation = Depends(get_u

for tool_config_key in marketplace_toolkit["configs"]:
ToolConfig.add_or_update(db.session, toolkit_id=update_toolkit.id,
key=tool_config_key["key"])
key=tool_config_key["key"], key_type = tool_config_key['key_type'], is_secret = tool_config_key['is_secret'], is_required = tool_config_key['is_required'])
12 changes: 10 additions & 2 deletions tests/unit_tests/controllers/test_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from superagi.models.organisation import Organisation
from superagi.models.tool import Tool
from superagi.models.tool_config import ToolConfig
from superagi.types.key_type import ToolConfigKeyType
from superagi.models.toolkit import Toolkit

client = TestClient(app)
Expand Down Expand Up @@ -86,11 +87,18 @@ def mock_toolkit_details():
"configs": [
{
"key": "config_key_1",
"value": "config_value_1"
"value": "config_value_1",
'key_type': ToolConfigKeyType.STRING,
'is_secret': True,
'is_required': False
},
{
"key": "config_key_2",
"value": "config_value_2"
"value": "config_value_2",
'key_type': ToolConfigKeyType.FILE,
'is_secret': True,
'is_required': False

}
]
}
Expand Down

0 comments on commit c990e16

Please sign in to comment.