Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ jobs:
- name: Install gptscript
run: |
curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe
- name: Create config file
run: |
echo '{"credsStore":"file"}' > config
- name: Run Tests
env:
GPTSCRIPT_BIN: .\gptscript.exe
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GPTSCRIPT_CONFIG: .\config
run: make test
18 changes: 16 additions & 2 deletions gptscript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestMain(m *testing.M) {
}

var err error
g, err = NewGPTScript(GlobalOptions{})
g, err = NewGPTScript(GlobalOptions{OpenAIAPIKey: os.Getenv("OPENAI_API_KEY")})
if err != nil {
panic(fmt.Sprintf("error creating gptscript: %s", err))
}
Expand Down Expand Up @@ -734,6 +734,20 @@ func TestConfirm(t *testing.T) {
for _, o := range e.Call.Output {
eventContent += o.Content
}

if e.Call.Type == EventTypeCallConfirm {
// On Windows, ls may not be recognized as a command. The LLM will try to run the dir command. Confirm it.
if !strings.Contains(e.Call.Input, "\"dir\"") {
t.Errorf("unexpected confirm input: %s", e.Call.Input)
}

if err = g.Confirm(context.Background(), AuthResponse{
ID: e.Call.ID,
Accept: true,
}); err != nil {
t.Errorf("Error confirming: %v", err)
}
}
}
}

Expand All @@ -742,7 +756,7 @@ func TestConfirm(t *testing.T) {
t.Errorf("Error reading output: %v", err)
}

if !strings.Contains(eventContent, "Makefile\nREADME.md") {
if !strings.Contains(eventContent, "Makefile") || !strings.Contains(eventContent, "README.md") {
t.Errorf("Unexpected event output: %s", eventContent)
}

Expand Down