Skip to content

Commit 5a5c1d9

Browse files
authored
Merge pull request #16 from thedadams/workspace-support
feat: add support for workspace gptscript feature
2 parents 2fd9480 + 0d22068 commit 5a5c1d9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ go.work
2424
.idea/
2525
.vscode/
2626

27+
bin/
28+
workspace/

exec.go

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Opts struct {
1818
Quiet bool `json:"quiet"`
1919
Chdir string `json:"chdir"`
2020
SubTool string `json:"subTool"`
21+
Workspace string `json:"workspace"`
2122
}
2223

2324
func (o Opts) toArgs() []string {
@@ -34,6 +35,9 @@ func (o Opts) toArgs() []string {
3435
if o.SubTool != "" {
3536
args = append(args, "--sub-tool="+o.SubTool)
3637
}
38+
if o.Workspace != "" {
39+
args = append(args, "--workspace="+o.Workspace)
40+
}
3741
return append(args, "--quiet="+fmt.Sprint(o.Quiet))
3842
}
3943

exec_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -500,3 +500,19 @@ echo hello there
500500
t.Errorf("Unexpected output: %s", out)
501501
}
502502
}
503+
504+
func TestExecWithWorkspace(t *testing.T) {
505+
tool := &SimpleTool{
506+
Tools: []string{"sys.workspace.ls", "sys.workspace.write"},
507+
Instructions: "Write a file named 'hello.txt' to the workspace with the content 'Hello!' and list the contents of the workspace.",
508+
}
509+
510+
out, err := ExecTool(context.Background(), Opts{Workspace: "./workspace"}, tool)
511+
if err != nil {
512+
t.Errorf("Error executing tool: %v", err)
513+
}
514+
515+
if !strings.Contains(out, "hello.txt") {
516+
t.Errorf("Unexpected output: %s", out)
517+
}
518+
}

0 commit comments

Comments
 (0)