Skip to content

Commit

Permalink
Toolkit configuration fix (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan1101 authored Aug 23, 2023
1 parent e19a7e9 commit 3e4b797
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions superagi/controllers/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ 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 @@ -363,5 +364,4 @@ def update_toolkit(toolkit_name: str, organisation: Organisation = Depends(get_u
toolkit_id=update_toolkit.id, description=tool["description"])

for tool_config_key in marketplace_toolkit["configs"]:
ToolConfig.add_or_update(db.session, toolkit_id=update_toolkit.id,
key=tool_config_key["key"])
ToolConfig.add_or_update(db.session, toolkit_id=update_toolkit.id, 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'])
13 changes: 10 additions & 3 deletions tests/unit_tests/controllers/test_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from fastapi.testclient import TestClient

from superagi.types.key_type import ToolConfigKeyType
from main import app
from superagi.models.organisation import Organisation
from superagi.models.tool import Tool
Expand Down Expand Up @@ -86,11 +86,18 @@ def mock_toolkit_details():
"configs": [
{
"key": "config_key_1",
"value": "config_value_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 3e4b797

Please sign in to comment.