Skip to content

Commit

Permalink
Updated tools.json format
Browse files Browse the repository at this point in the history
  • Loading branch information
luciferlinx101 committed Jul 2, 2023
1 parent 3845abe commit 09cf340
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions superagi/helper/tool_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ def register_toolkits(session, organisation):
logger.info(f"Toolkits Registered Successfully for Organisation ID : {organisation.id}!")


def extract_repo_name(repo_link):
def extract_repo_name_with_username(repo_link):
# Extract the repository name from the link
# Assuming the GitHub link format: https://github.com/username/repoName
repo_name = repo_link.rsplit('/', 1)[-1]
username_repo = repo_link.rsplit('/', 2)[-2:]
user_repo_key = "/".join(username_repo)

return repo_name
return user_repo_key


def add_tool_to_json(repo_link):
Expand All @@ -262,7 +263,7 @@ def add_tool_to_json(repo_link):
tools_data = json.load(file)

# Extract the repository name from the link
repo_name = extract_repo_name(repo_link)
repo_name = extract_repo_name_with_username(repo_link)

# Add a new key-value pair to the tools object
tools_data['tools'][repo_name] = repo_link
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/helper/test_tool_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from superagi.helper.tool_helper import (
parse_github_url,
load_module_from_file,
extract_repo_name,
extract_repo_name_with_username,
add_tool_to_json, get_readme_content_from_code_link, download_tool
)

Expand Down Expand Up @@ -73,8 +73,8 @@ def test_get_readme_content_from_code_link(mock_requests_get):

def test_extract_repo_name():
repo_link = 'https://github.com/username/repo'
expected_result = 'repo'
assert extract_repo_name(repo_link) == expected_result
expected_result = 'username/repo'
assert extract_repo_name_with_username(repo_link) == expected_result


@patch('requests.get')
Expand Down

0 comments on commit 09cf340

Please sign in to comment.