-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from ibuildthecloud/main
Fix http tool lookups that are on the root of the domain
- Loading branch information
Showing
2 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,99 @@ | ||
package loader | ||
|
||
import "testing" | ||
import ( | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
|
||
func TestLoader(*testing.T) { | ||
"github.com/hexops/autogold/v2" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func toString(obj any) string { | ||
s, err := json.MarshalIndent(obj, "", " ") | ||
if err != nil { | ||
panic(err) | ||
} | ||
return string(s) | ||
} | ||
|
||
func TestHelloWorld(t *testing.T) { | ||
prg, err := Program(context.Background(), | ||
"https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt", | ||
"") | ||
require.NoError(t, err) | ||
autogold.Expect(`{ | ||
"name": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt", | ||
"entryToolId": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt:1", | ||
"toolSet": { | ||
"https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/bob.gpt:1": { | ||
"modelName": "gpt-4-turbo-preview", | ||
"internalPrompt": null, | ||
"instructions": "Say hello world", | ||
"id": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/bob.gpt:1", | ||
"localTools": { | ||
"": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/bob.gpt:1" | ||
}, | ||
"source": { | ||
"location": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/bob.gpt", | ||
"lineNo": 1 | ||
}, | ||
"workingDir": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example" | ||
}, | ||
"https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt:1": { | ||
"modelName": "gpt-4-turbo-preview", | ||
"internalPrompt": null, | ||
"tools": [ | ||
"../bob.gpt" | ||
], | ||
"instructions": "call bob", | ||
"id": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt:1", | ||
"toolMapping": { | ||
"../bob.gpt": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/bob.gpt:1" | ||
}, | ||
"localTools": { | ||
"": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt:1" | ||
}, | ||
"source": { | ||
"location": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub/tool.gpt", | ||
"lineNo": 1 | ||
}, | ||
"workingDir": "https://raw.githubusercontent.com/ibuildthecloud/test/bafe5a62174e8a0ea162277dcfe3a2ddb7eea928/example/sub" | ||
} | ||
} | ||
}`).Equal(t, toString(prg)) | ||
|
||
prg, err = Program(context.Background(), "https://get.gptscript.ai/echo.gpt", "") | ||
require.NoError(t, err) | ||
|
||
autogold.Expect(`{ | ||
"name": "https://get.gptscript.ai/echo.gpt", | ||
"entryToolId": "https://get.gptscript.ai/echo.gpt:1", | ||
"toolSet": { | ||
"https://get.gptscript.ai/echo.gpt:1": { | ||
"description": "Returns back the input of the script", | ||
"modelName": "gpt-4-turbo-preview", | ||
"internalPrompt": null, | ||
"arguments": { | ||
"type": "object", | ||
"properties": { | ||
"input": { | ||
"description": " Any string", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"instructions": "echo \"${input}\"", | ||
"id": "https://get.gptscript.ai/echo.gpt:1", | ||
"localTools": { | ||
"": "https://get.gptscript.ai/echo.gpt:1" | ||
}, | ||
"source": { | ||
"location": "https://get.gptscript.ai/echo.gpt", | ||
"lineNo": 1 | ||
}, | ||
"workingDir": "https://get.gptscript.ai/" | ||
} | ||
} | ||
}`).Equal(t, toString(prg)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters