diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 92a797f..ac670ec 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -13,6 +13,8 @@ jobs: runs-on: macos-14 steps: - uses: actions/checkout@v4 + - name: Change Xcode version + run: sudo xcode-select -s /Applications/Xcode_16.2.app - name: Install swiftlint run: | brew update diff --git a/Package.swift b/Package.swift index 760fe3a..b110d64 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/fumito-ito/FunctionCalling", from: "0.5.0"), - .package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "11.11.0") + .package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "11.13.0") ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Tests/FunctionCalling-FirebaseVertexAITests/Extensions.swift b/Tests/FunctionCalling-FirebaseVertexAITests/Extensions.swift deleted file mode 100644 index 8efe9a5..0000000 --- a/Tests/FunctionCalling-FirebaseVertexAITests/Extensions.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Extensions.swift -// FunctionCalling-FirebaseVertexAI -// -// Created by 伊藤史 on 2024/09/20. -// - -@testable import FirebaseVertexAI - -extension FirebaseVertexAI.Tool { - var functions: [FirebaseVertexAI.FunctionDeclaration]? { - functionDeclarations - } -} - -extension FirebaseVertexAI.FunctionDeclaration { - func getName() -> String { - name - } - - func getDescription() -> String { - description - } -} diff --git a/Tests/FunctionCalling-FirebaseVertexAITests/FunctionCalling_FirebaseVertexAITests.swift b/Tests/FunctionCalling-FirebaseVertexAITests/FunctionCalling_FirebaseVertexAITests.swift index 05fd7e4..0d60b14 100644 --- a/Tests/FunctionCalling-FirebaseVertexAITests/FunctionCalling_FirebaseVertexAITests.swift +++ b/Tests/FunctionCalling-FirebaseVertexAITests/FunctionCalling_FirebaseVertexAITests.swift @@ -21,20 +21,31 @@ final class FunctionCalling_FirebaseVertexAITests: XCTestCase { } func testConvertedResults() throws { - guard let functions = FunctionContainer().firebaseVertexAITools.first?.functions else { + guard let tool = FunctionContainer().firebaseVertexAITools.first else { XCTFail("Conainer should contain some functions") return } + let encodedToolData = try JSONEncoder().encode(tool) + let jsonObject = try JSONSerialization.jsonObject(with: encodedToolData) + + guard let toolDictionary = jsonObject as? [String: Any] else { + XCTFail("Failed to convert to JSON object") + return + } + + guard let functions = toolDictionary["functionDeclarations"] as? [[String: Any]] else { + XCTFail("Failed to convert to JSON object") + return + } + XCTAssertEqual(functions.count, 2) - let getWeather = try XCTUnwrap(functions.first) - XCTAssertEqual(getWeather.getName(), "getWeather") + let getWeather = try XCTUnwrap(functions.first(where: { $0["name"] as? String == "getWeather" })) // swiftlint:disable:next line_length - XCTAssertEqual(getWeather.getDescription(), "Return current weather of location that passed by the argument- Parameter location: location that I want to know how the weather- Returns: string of weather") + XCTAssertEqual(getWeather["description"] as? String, "Return current weather of location that passed by the argument- Parameter location: location that I want to know how the weather- Returns: string of weather") - let getStock = try XCTUnwrap(functions.last) - XCTAssertEqual(getStock.getName(), "getStock") - XCTAssertEqual(getStock.getDescription(), "") + let getStock = try XCTUnwrap(functions.first(where: { $0["name"] as? String == "getStock" })) + XCTAssertEqual(getStock["description"] as? String, "") } }