Skip to content

Commit b812e48

Browse files
committed
use FunctionCalling with 0.4.0
1 parent 913dd8f commit b812e48

3 files changed

Lines changed: 12 additions & 17 deletions

File tree

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
@@ -16,7 +16,7 @@ let package = Package(
1616
targets: ["FunctionCalling-AWSBedrock"]),
1717
],
1818
dependencies: [
19-
.package(url: "https://github.com/FunctionCalling/FunctionCalling", from: "0.3.0"),
19+
.package(url: "https://github.com/FunctionCalling/FunctionCalling", from: "0.4.0"),
2020
.package(url: "https://github.com/awslabs/aws-sdk-swift", from: "0.77.1"),
2121
],
2222
targets: [

Sources/FunctionCalling-AWSBedrock/FunctionCalling-AWSBedrock.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,15 @@ import FunctionCalling
55
import AWSBedrockRuntime
66
import Foundation
77

8-
let decoder: JSONDecoder = {
9-
let decoder = JSONDecoder()
10-
decoder.keyDecodingStrategy = .convertFromSnakeCase
11-
12-
return decoder
13-
}()
14-
158
extension ToolContainer {
169
typealias FunctionCallingTool = FunctionCalling.Tool
1710

1811
public var bedrockAllTools: [BedrockRuntimeClientTypes.Tool] {
1912
get throws {
20-
let data = allTools.replacingOccurrences(of: "\n", with: "").data(using: .utf8)!
21-
let functionCallingTools = try decoder.decode([FunctionCallingTool].self, from: data)
13+
guard let functionCallingTools = allTools else {
14+
return []
15+
}
16+
2217
return try functionCallingTools.map { try $0.toBedrockTool }
2318
}
2419
}

0 commit comments

Comments
 (0)