Skip to content

Commit

Permalink
Merge pull request #17 from thedadams/add-sub-tools
Browse files Browse the repository at this point in the history
feat: add support for subTool option
  • Loading branch information
thedadams authored Apr 26, 2024
2 parents 62c8113 + af4508b commit d13ff51
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@ on:
required: true

jobs:
check-perms:
runs-on: ubuntu-latest
steps:
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1
test-linux:
needs: check-perms
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ opts= {
"cache-dir": "/path/to/dir",
"quiet": True|False(default),
"chdir": "/path/to/dir",
"subTool": "tool-name",
}

Cache can be set to true or false to enable or disable caching globally or it can be set at the individual tool level. The cache-dir can be set to a directory to use for caching. If not set, the default cache directory will be used.
Expand Down
1 change: 1 addition & 0 deletions gptscript/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"cacheDir": "--cache-dir=",
"quiet": "--quiet=",
"chdir": "--chdir=",
"subTool": "--sub-tool=",
}


Expand Down
10 changes: 8 additions & 2 deletions tests/test_gptscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def complex_tool():
@pytest.fixture
def tool_list():
return [
Tool(tools=["echo"], instructions="echo hello times"),
Tool(tools=["echo"], instructions="echo hello there"),
Tool(name="other", tools=["echo"], instructions="echo hello somewhere else"),
Tool(
name="echo",
tools=["sys.exec"],
Expand Down Expand Up @@ -104,7 +105,12 @@ def test_exec_complex_tool(complex_tool):
# Test execution with a list of tools
def test_exec_tool_list(tool_list):
out, err = exec(tool_list)
assert out is not None, "Expected some output from exec using a list of tools"
assert out.strip() == "hello there", "Unexpected output from exec using a list of tools"


def test_exec_tool_list_with_sub_tool(tool_list):
out, err = exec(tool_list, opts={"subTool": "other"})
assert out.strip() == "hello somewhere else", "Unexpected output from exec using a list of tools with sub tool"


# Test streaming execution of a complex tool
Expand Down

0 comments on commit d13ff51

Please sign in to comment.