Skip to content

Commit 4e44d94

Browse files
authored
Merge pull request #13 from FunctionCalling/renovate/macpaw-openai-0.x
Update dependency MacPaw/OpenAI to from: "0.4.3"
2 parents 739af46 + 731cb2e commit 4e44d94

File tree

3 files changed

+19
-48
lines changed

3 files changed

+19
-48
lines changed

Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
],
1818
dependencies: [
1919
.package(url: "https://github.com/FunctionCalling/FunctionCalling", from: "0.5.0"),
20-
.package(url: "https://github.com/MacPaw/OpenAI", from: "0.4.1")
20+
.package(url: "https://github.com/MacPaw/OpenAI", from: "0.4.3")
2121
],
2222
targets: [
2323
// Targets are the basic building blocks of a package, defining a module or a test suite.

Sources/FunctionCalling-MacPaw-OpenAI/Extension/ChatQuery+Extension.swift

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,25 @@ extension ChatQuery.ChatCompletionToolParam.FunctionDefinition {
1919
self.init(
2020
name: tool.name,
2121
description: tool.description,
22-
parameters: FunctionParameters(inputSchema: tool.inputSchema)
22+
parameters: AnyJSONSchema(inputSchema: tool.inputSchema)
2323
)
2424
}
2525
}
2626

27-
extension ChatQuery.ChatCompletionToolParam.FunctionDefinition.FunctionParameters {
27+
extension AnyJSONSchema {
2828
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+
])
6435
}
6536
}
6637

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 {
7041
case .string:
7142
self = .string
7243
case .number:

0 commit comments

Comments
 (0)