Skip to content

Commit 52e31f5

Browse files
Merge pull request #571 from ibuildthecloud/main
bug: go back to old behavior of dropping {} for tools
2 parents 8c6a1d2 + 7d2aeb3 commit 52e31f5

File tree

28 files changed

+49
-46
lines changed

28 files changed

+49
-46
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86
1717
github.com/gptscript-ai/chat-completion-client v0.0.0-20240531200700-af8e7ecf0379
1818
github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d
19-
github.com/gptscript-ai/tui v0.0.0-20240627001757-8b452fa47eb5
19+
github.com/gptscript-ai/tui v0.0.0-20240627044440-d416df63c10d
2020
github.com/hexops/autogold/v2 v2.2.1
2121
github.com/hexops/valast v1.4.4
2222
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d h1:sKf7T7twhGXs6A
173173
github.com/gptscript-ai/cmd v0.0.0-20240625175447-4250b42feb7d/go.mod h1:DJAo1xTht1LDkNYFNydVjTHd576TC7MlpsVRl3oloVw=
174174
github.com/gptscript-ai/go-gptscript v0.0.0-20240625134437-4b83849794cc h1:ABV7VAK65YBkqL7VlNp5ryVXnRqkKQ+U/NZfUO3ypqA=
175175
github.com/gptscript-ai/go-gptscript v0.0.0-20240625134437-4b83849794cc/go.mod h1:Dh6vYRAiVcyC3ElZIGzTvNF1FxtYwA07BHfSiFKQY7s=
176-
github.com/gptscript-ai/tui v0.0.0-20240627001757-8b452fa47eb5 h1:knDhTTJNqaZB1XMudXJuVVnTqj9USrXzNfsl1nTqKXA=
177-
github.com/gptscript-ai/tui v0.0.0-20240627001757-8b452fa47eb5/go.mod h1:NwFdBDmGQvjLFFDnSRBRakkhw0MIO1sSdRnWNk4cCQ0=
176+
github.com/gptscript-ai/tui v0.0.0-20240627044440-d416df63c10d h1:hbJ5rkwMDDntqbvHMbsEoP8Nsa5nqTOzF+ktkw3uDQQ=
177+
github.com/gptscript-ai/tui v0.0.0-20240627044440-d416df63c10d/go.mod h1:NwFdBDmGQvjLFFDnSRBRakkhw0MIO1sSdRnWNk4cCQ0=
178178
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
179179
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
180180
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=

pkg/openai/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ func toMessages(request types.CompletionRequest, compat bool) (result []openai.C
276276
}
277277

278278
if len(chatMessage.MultiContent) == 1 && chatMessage.MultiContent[0].Type == openai.ChatMessagePartTypeText {
279+
if !request.Chat && strings.TrimSpace(chatMessage.MultiContent[0].Text) == "{}" {
280+
continue
281+
}
279282
chatMessage.Content = chatMessage.MultiContent[0].Text
280283
chatMessage.MultiContent = nil
281284

pkg/system/prompt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ You don't move to the next step until you have a result.
2424

2525
// DefaultPromptParameter is used as the key in a json map to indication that we really wanted
2626
// to just send pure text but the interface required JSON (as that is the fundamental interface of tools in OpenAI)
27-
var DefaultPromptParameter = "prompt"
27+
var DefaultPromptParameter = "defaultPromptParameter"
2828

2929
var DefaultToolSchema = openapi3.Schema{
3030
Type: &openapi3.Types{"object"},

pkg/tests/runner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func TestSubChat(t *testing.T) {
322322
"name": "chatbot",
323323
"parameters": {
324324
"properties": {
325-
"prompt": {
325+
"defaultPromptParameter": {
326326
"description": "Prompt to send to the assistant. This may be an instruction or question.",
327327
"type": "string"
328328
}
@@ -447,7 +447,7 @@ func TestSubChat(t *testing.T) {
447447
"name": "chatbot",
448448
"parameters": {
449449
"properties": {
450-
"prompt": {
450+
"defaultPromptParameter": {
451451
"description": "Prompt to send to the assistant. This may be an instruction or question.",
452452
"type": "string"
453453
}

pkg/tests/testdata/TestAgents/call1.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "agent1",
99
"parameters": {
1010
"properties": {
11-
"prompt": {
11+
"defaultPromptParameter": {
1212
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1313
"type": "string"
1414
}
@@ -23,7 +23,7 @@
2323
"name": "agent2",
2424
"parameters": {
2525
"properties": {
26-
"prompt": {
26+
"defaultPromptParameter": {
2727
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2828
"type": "string"
2929
}

pkg/tests/testdata/TestAgents/call2.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "agent2",
99
"parameters": {
1010
"properties": {
11-
"prompt": {
11+
"defaultPromptParameter": {
1212
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1313
"type": "string"
1414
}

pkg/tests/testdata/TestAgents/call3.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "agent1",
99
"parameters": {
1010
"properties": {
11-
"prompt": {
11+
"defaultPromptParameter": {
1212
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1313
"type": "string"
1414
}
@@ -23,7 +23,7 @@
2323
"name": "agent3",
2424
"parameters": {
2525
"properties": {
26-
"prompt": {
26+
"defaultPromptParameter": {
2727
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2828
"type": "string"
2929
}

pkg/tests/testdata/TestAgents/step1.golden

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"name": "agent1",
1717
"parameters": {
1818
"properties": {
19-
"prompt": {
19+
"defaultPromptParameter": {
2020
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2121
"type": "string"
2222
}
@@ -31,7 +31,7 @@
3131
"name": "agent2",
3232
"parameters": {
3333
"properties": {
34-
"prompt": {
34+
"defaultPromptParameter": {
3535
"description": "Prompt to send to the assistant. This may be an instruction or question.",
3636
"type": "string"
3737
}
@@ -111,7 +111,7 @@
111111
"name": "agent2",
112112
"parameters": {
113113
"properties": {
114-
"prompt": {
114+
"defaultPromptParameter": {
115115
"description": "Prompt to send to the assistant. This may be an instruction or question.",
116116
"type": "string"
117117
}
@@ -182,7 +182,7 @@
182182
"name": "agent1",
183183
"parameters": {
184184
"properties": {
185-
"prompt": {
185+
"defaultPromptParameter": {
186186
"description": "Prompt to send to the assistant. This may be an instruction or question.",
187187
"type": "string"
188188
}
@@ -197,7 +197,7 @@
197197
"name": "agent3",
198198
"parameters": {
199199
"properties": {
200-
"prompt": {
200+
"defaultPromptParameter": {
201201
"description": "Prompt to send to the assistant. This may be an instruction or question.",
202202
"type": "string"
203203
}

pkg/tests/testdata/TestAsterick/call1.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "afoo",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the tool. This may be an instruction or question.",
1212
"type": "string"
1313
}
@@ -22,7 +22,7 @@
2222
"name": "a",
2323
"parameters": {
2424
"properties": {
25-
"prompt": {
25+
"defaultPromptParameter": {
2626
"description": "Prompt to send to the tool. This may be an instruction or question.",
2727
"type": "string"
2828
}

pkg/tests/testdata/TestContextSubChat/call1.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}

pkg/tests/testdata/TestContextSubChat/call4.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}

pkg/tests/testdata/TestContextSubChat/call6.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}

pkg/tests/testdata/TestContextSubChat/call9.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}

pkg/tests/testdata/TestContextSubChat/step1.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"name": "chatbot",
1616
"parameters": {
1717
"properties": {
18-
"prompt": {
18+
"defaultPromptParameter": {
1919
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2020
"type": "string"
2121
}

pkg/tests/testdata/TestContextSubChat/step3.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"name": "chatbot",
5858
"parameters": {
5959
"properties": {
60-
"prompt": {
60+
"defaultPromptParameter": {
6161
"description": "Prompt to send to the assistant. This may be an instruction or question.",
6262
"type": "string"
6363
}

pkg/tests/testdata/TestDualSubChat/call1.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}
@@ -22,7 +22,7 @@
2222
"name": "chatbot2",
2323
"parameters": {
2424
"properties": {
25-
"prompt": {
25+
"defaultPromptParameter": {
2626
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2727
"type": "string"
2828
}

pkg/tests/testdata/TestDualSubChat/call7.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}
@@ -22,7 +22,7 @@
2222
"name": "chatbot2",
2323
"parameters": {
2424
"properties": {
25-
"prompt": {
25+
"defaultPromptParameter": {
2626
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2727
"type": "string"
2828
}

pkg/tests/testdata/TestDualSubChat/step1.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"name": "chatbot",
1616
"parameters": {
1717
"properties": {
18-
"prompt": {
18+
"defaultPromptParameter": {
1919
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2020
"type": "string"
2121
}
@@ -30,7 +30,7 @@
3030
"name": "chatbot2",
3131
"parameters": {
3232
"properties": {
33-
"prompt": {
33+
"defaultPromptParameter": {
3434
"description": "Prompt to send to the assistant. This may be an instruction or question.",
3535
"type": "string"
3636
}

pkg/tests/testdata/TestDualSubChat/step2.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"name": "chatbot",
1616
"parameters": {
1717
"properties": {
18-
"prompt": {
18+
"defaultPromptParameter": {
1919
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2020
"type": "string"
2121
}
@@ -30,7 +30,7 @@
3030
"name": "chatbot2",
3131
"parameters": {
3232
"properties": {
33-
"prompt": {
33+
"defaultPromptParameter": {
3434
"description": "Prompt to send to the assistant. This may be an instruction or question.",
3535
"type": "string"
3636
}

pkg/tests/testdata/TestDualSubChat/step3.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"name": "chatbot",
1616
"parameters": {
1717
"properties": {
18-
"prompt": {
18+
"defaultPromptParameter": {
1919
"description": "Prompt to send to the assistant. This may be an instruction or question.",
2020
"type": "string"
2121
}
@@ -30,7 +30,7 @@
3030
"name": "chatbot2",
3131
"parameters": {
3232
"properties": {
33-
"prompt": {
33+
"defaultPromptParameter": {
3434
"description": "Prompt to send to the assistant. This may be an instruction or question.",
3535
"type": "string"
3636
}

pkg/tests/testdata/TestExport/call1.golden

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "frommain",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the tool. This may be an instruction or question.",
1212
"type": "string"
1313
}
@@ -22,7 +22,7 @@
2222
"name": "parentLocal",
2323
"parameters": {
2424
"properties": {
25-
"prompt": {
25+
"defaultPromptParameter": {
2626
"description": "Prompt to send to the tool. This may be an instruction or question.",
2727
"type": "string"
2828
}
@@ -37,7 +37,7 @@
3737
"name": "transient",
3838
"parameters": {
3939
"properties": {
40-
"prompt": {
40+
"defaultPromptParameter": {
4141
"description": "Prompt to send to the tool. This may be an instruction or question.",
4242
"type": "string"
4343
}

pkg/tests/testdata/TestExport/call3.golden

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "frommain",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the tool. This may be an instruction or question.",
1212
"type": "string"
1313
}
@@ -22,7 +22,7 @@
2222
"name": "parentLocal",
2323
"parameters": {
2424
"properties": {
25-
"prompt": {
25+
"defaultPromptParameter": {
2626
"description": "Prompt to send to the tool. This may be an instruction or question.",
2727
"type": "string"
2828
}
@@ -37,7 +37,7 @@
3737
"name": "transient",
3838
"parameters": {
3939
"properties": {
40-
"prompt": {
40+
"defaultPromptParameter": {
4141
"description": "Prompt to send to the tool. This may be an instruction or question.",
4242
"type": "string"
4343
}

pkg/tests/testdata/TestExportContext/call1.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "subtool",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the tool. This may be an instruction or question.",
1212
"type": "string"
1313
}

pkg/tests/testdata/TestSubChat/call1.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "chatbot",
88
"parameters": {
99
"properties": {
10-
"prompt": {
10+
"defaultPromptParameter": {
1111
"description": "Prompt to send to the assistant. This may be an instruction or question.",
1212
"type": "string"
1313
}

pkg/tests/testdata/TestSysContext/call1.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "iAmSuperman",
99
"parameters": {
1010
"properties": {
11-
"prompt": {
11+
"defaultPromptParameter": {
1212
"description": "Prompt to send to the tool. This may be an instruction or question.",
1313
"type": "string"
1414
}

pkg/tests/testdata/TestSysContext/step1.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"name": "iAmSuperman",
1717
"parameters": {
1818
"properties": {
19-
"prompt": {
19+
"defaultPromptParameter": {
2020
"description": "Prompt to send to the tool. This may be an instruction or question.",
2121
"type": "string"
2222
}

0 commit comments

Comments
 (0)