File tree Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ var toolWithObjects = []openai.ChatCompletionToolParam{
218
218
"type" : "string" ,
219
219
},
220
220
"quantity" : map [string ]string {
221
- "type" : "number " ,
221
+ "type" : "integer " ,
222
222
},
223
223
"address" : map [string ]interface {}{
224
224
"type" : "object" ,
@@ -227,7 +227,7 @@ var toolWithObjects = []openai.ChatCompletionToolParam{
227
227
"type" : "string" ,
228
228
},
229
229
"number" : map [string ]interface {}{
230
- "type" : "number " ,
230
+ "type" : "integer " ,
231
231
},
232
232
"home" : map [string ]interface {}{
233
233
"type" : "boolean" ,
@@ -264,7 +264,7 @@ var toolWithObjectAndArray = []openai.ChatCompletionToolParam{
264
264
"description" : "The user's name" ,
265
265
},
266
266
"age" : map [string ]string {
267
- "type" : "number " ,
267
+ "type" : "integer " ,
268
268
"description" : "The user's age" ,
269
269
},
270
270
"hobbies" : map [string ]interface {}{
@@ -496,7 +496,7 @@ var _ = Describe("Simulator for request with tools", func() {
496
496
Expect (tc .Function .Name ).To (Equal ("multiply_numbers" ))
497
497
Expect (tc .ID ).NotTo (BeEmpty ())
498
498
Expect (string (tc .Type )).To (Equal ("function" ))
499
- args := make (map [string ][]int )
499
+ args := make (map [string ][]float64 )
500
500
err = json .Unmarshal ([]byte (tc .Function .Arguments ), & args )
501
501
Expect (err ).NotTo (HaveOccurred ())
502
502
Expect (args ["numbers" ]).ToNot (BeEmpty ())
Original file line number Diff line number Diff line change @@ -142,8 +142,10 @@ func createArgument(property any) (any, error) {
142
142
switch paramType {
143
143
case "string" :
144
144
return getStringArgument (), nil
145
- case "number " :
145
+ case "integer " :
146
146
return randomInt (0 , 100 ), nil
147
+ case "number" :
148
+ return randomFloat (0 , 100 ), nil
147
149
case "boolean" :
148
150
return flipCoin (), nil
149
151
case "array" :
@@ -250,6 +252,7 @@ const schema = `{
250
252
"array",
251
253
"string",
252
254
"number",
255
+ "integer",
253
256
"boolean",
254
257
"null"
255
258
]
@@ -308,6 +311,7 @@ const schema = `{
308
311
"enum": [
309
312
"string",
310
313
"number",
314
+ "integer",
311
315
"boolean",
312
316
"array",
313
317
"object",
@@ -323,6 +327,7 @@ const schema = `{
323
327
"type": [
324
328
"string",
325
329
"number",
330
+ "integer",
326
331
"boolean"
327
332
]
328
333
}
@@ -404,6 +409,25 @@ const schema = `{
404
409
}
405
410
}
406
411
},
412
+ {
413
+ "if": {
414
+ "properties": {
415
+ "type": {
416
+ "const": "integer"
417
+ }
418
+ }
419
+ },
420
+ "then": {
421
+ "properties": {
422
+ "enum": {
423
+ "type": "array",
424
+ "items": {
425
+ "type": "integer"
426
+ }
427
+ }
428
+ }
429
+ }
430
+ },
407
431
{
408
432
"if": {
409
433
"properties": {
Original file line number Diff line number Diff line change @@ -123,6 +123,13 @@ func flipCoin() bool {
123
123
return randomInt (0 , 1 ) != 0
124
124
}
125
125
126
+ // Returns a random float64 in the range [min, max)
127
+ func randomFloat (min float64 , max float64 ) float64 {
128
+ src := rand .NewSource (time .Now ().UnixNano ())
129
+ r := rand .New (src )
130
+ return r .Float64 ()* (max - min ) + min
131
+ }
132
+
126
133
// Regular expression for the response tokenization
127
134
var re * regexp.Regexp
128
135
You can’t perform that action at this time.
0 commit comments