@@ -19,54 +19,25 @@ extension ChatQuery.ChatCompletionToolParam.FunctionDefinition {
19
19
self . init (
20
20
name: tool. name,
21
21
description: tool. description,
22
- parameters: FunctionParameters ( inputSchema: tool. inputSchema)
22
+ parameters: AnyJSONSchema ( inputSchema: tool. inputSchema)
23
23
)
24
24
}
25
25
}
26
26
27
- extension ChatQuery . ChatCompletionToolParam . FunctionDefinition . FunctionParameters {
27
+ extension AnyJSONSchema {
28
28
init ( inputSchema: InputSchema ) {
29
- self . init (
30
- type: JSONType ( dataType: inputSchema. type) ,
31
- properties: inputSchema. properties? . mapValues { Property ( inputSchema: $0) } ,
32
- required: inputSchema. requiredProperties,
33
- enum: inputSchema. enumValues
34
- )
35
- }
36
- }
37
-
38
- extension ChatQuery . ChatCompletionToolParam . FunctionDefinition . FunctionParameters . Property . Items {
39
- init ? ( inputSchema: InputSchema ? ) {
40
- guard let inputSchema else {
41
- return nil
42
- }
43
-
44
- self . init (
45
- type: JSONType ( dataType: inputSchema. type) ,
46
- properties: inputSchema. properties? . mapValues {
47
- ChatQuery . ChatCompletionToolParam. FunctionDefinition. FunctionParameters. Property ( inputSchema: $0)
48
- } ,
49
- enum: inputSchema. enumValues
50
- )
51
- }
52
- }
53
-
54
- extension ChatQuery . ChatCompletionToolParam . FunctionDefinition . FunctionParameters . Property {
55
- init ( inputSchema: InputSchema ) {
56
- self . init (
57
- type: JSONType ( dataType: inputSchema. type) ,
58
- description: inputSchema. description,
59
- format: inputSchema. format,
60
- items: Items ( inputSchema: inputSchema. items) ,
61
- required: inputSchema. requiredProperties,
62
- enum: inputSchema. enumValues
63
- )
29
+ self . init ( fields: [
30
+ . type( JSONSchemaInstanceType ( type: inputSchema. type) ) ,
31
+ . properties( inputSchema. properties? . mapValues { AnyJSONSchema ( inputSchema: $0) } ?? [ : ] ) ,
32
+ . required( inputSchema. requiredProperties ?? [ ] ) ,
33
+ . enumValues( inputSchema. enumValues ?? [ ] )
34
+ ] )
64
35
}
65
36
}
66
37
67
- extension ChatQuery . ChatCompletionToolParam . FunctionDefinition . FunctionParameters . JSONType {
68
- init ( dataType : InputSchema . DataType ) {
69
- switch dataType {
38
+ extension JSONSchemaInstanceType {
39
+ init ( type : InputSchema . DataType ) {
40
+ switch type {
70
41
case . string:
71
42
self = . string
72
43
case . number:
0 commit comments