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{
218218 "type" : "string" ,
219219 },
220220 "quantity" : map [string ]string {
221- "type" : "number " ,
221+ "type" : "integer " ,
222222 },
223223 "address" : map [string ]interface {}{
224224 "type" : "object" ,
@@ -227,7 +227,7 @@ var toolWithObjects = []openai.ChatCompletionToolParam{
227227 "type" : "string" ,
228228 },
229229 "number" : map [string ]interface {}{
230- "type" : "number " ,
230+ "type" : "integer " ,
231231 },
232232 "home" : map [string ]interface {}{
233233 "type" : "boolean" ,
@@ -264,7 +264,7 @@ var toolWithObjectAndArray = []openai.ChatCompletionToolParam{
264264 "description" : "The user's name" ,
265265 },
266266 "age" : map [string ]string {
267- "type" : "number " ,
267+ "type" : "integer " ,
268268 "description" : "The user's age" ,
269269 },
270270 "hobbies" : map [string ]interface {}{
@@ -496,7 +496,7 @@ var _ = Describe("Simulator for request with tools", func() {
496496 Expect (tc .Function .Name ).To (Equal ("multiply_numbers" ))
497497 Expect (tc .ID ).NotTo (BeEmpty ())
498498 Expect (string (tc .Type )).To (Equal ("function" ))
499- args := make (map [string ][]int )
499+ args := make (map [string ][]float64 )
500500 err = json .Unmarshal ([]byte (tc .Function .Arguments ), & args )
501501 Expect (err ).NotTo (HaveOccurred ())
502502 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) {
142142 switch paramType {
143143 case "string" :
144144 return getStringArgument (), nil
145- case "number " :
145+ case "integer " :
146146 return randomInt (0 , 100 ), nil
147+ case "number" :
148+ return randomFloat (0 , 100 ), nil
147149 case "boolean" :
148150 return flipCoin (), nil
149151 case "array" :
@@ -250,6 +252,7 @@ const schema = `{
250252 "array",
251253 "string",
252254 "number",
255+ "integer",
253256 "boolean",
254257 "null"
255258 ]
@@ -308,6 +311,7 @@ const schema = `{
308311 "enum": [
309312 "string",
310313 "number",
314+ "integer",
311315 "boolean",
312316 "array",
313317 "object",
@@ -323,6 +327,7 @@ const schema = `{
323327 "type": [
324328 "string",
325329 "number",
330+ "integer",
326331 "boolean"
327332 ]
328333 }
@@ -404,6 +409,25 @@ const schema = `{
404409 }
405410 }
406411 },
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+ },
407431 {
408432 "if": {
409433 "properties": {
Original file line number Diff line number Diff line change @@ -123,6 +123,13 @@ func flipCoin() bool {
123123 return randomInt (0 , 1 ) != 0
124124}
125125
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+
126133// Regular expression for the response tokenization
127134var re * regexp.Regexp
128135
You can’t perform that action at this time.
0 commit comments