Skip to content

Commit 745592b

Browse files
authored
Merge pull request #1 from FunctionCalling/feature/bump-dependencies
bump dependencies
2 parents 8edae6c + 45067d0 commit 745592b

File tree

5 files changed

+65
-17
lines changed

5 files changed

+65
-17
lines changed

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let package = Package(
1616
targets: ["FunctionCalling-FirebaseVertexAI"]),
1717
],
1818
dependencies: [
19-
.package(url: "https://github.com/fumito-ito/FunctionCalling", from: "0.3.0"),
20-
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "10.4.0")
19+
.package(url: "https://github.com/fumito-ito/FunctionCalling", from: "0.4.0"),
20+
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "11.2.0")
2121
],
2222
targets: [
2323
// Targets are the basic building blocks of a package, defining a module or a test suite.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let package = Package(
4848
)
4949
],
5050
dependencies: [
51-
.package(url: "https://github.com/FunctionCalling/FunctionCalling-FirebaseVertexAI", from: "0.0.1")
51+
.package(url: "https://github.com/FunctionCalling/FunctionCalling-FirebaseVertexAI", from: "0.1.0")
5252
]
5353
)
5454
```

Sources/FunctionCalling-FirebaseVertexAI/FunctionCalling_FirebaseVertexAI.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import FunctionCalling
99
import FirebaseVertexAI
1010
import Foundation
1111

12-
typealias FunctionCallingTool = FunctionCalling.Tool
13-
1412
extension ToolContainer {
1513
public var firebaseVertexAITools: [FirebaseVertexAI.Tool] {
16-
get throws {
17-
let data = allTools.data(using: .utf8)!
18-
let functionCallingTools = try JSONDecoder().decode([FunctionCallingTool].self, from: data)
19-
let firebaseVertexAITools = functionCallingTools.map { $0.toFunctionDeclaration }
20-
21-
return [FirebaseVertexAI.Tool(functionDeclarations: firebaseVertexAITools)]
14+
get {
15+
[
16+
FirebaseVertexAI.Tool(
17+
functionDeclarations: allTools?.compactMap { $0.toFunctionDeclaration }
18+
)
19+
]
2220
}
2321
}
2422
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Extensions.swift
3+
// FunctionCalling-FirebaseVertexAI
4+
//
5+
// Created by 伊藤史 on 2024/09/20.
6+
//
7+
8+
@testable import FirebaseVertexAI
9+
10+
extension FirebaseVertexAI.Tool {
11+
var functions: [FirebaseVertexAI.FunctionDeclaration]? {
12+
functionDeclarations
13+
}
14+
}
15+
16+
extension FirebaseVertexAI.FunctionDeclaration {
17+
func getName() -> String {
18+
name
19+
}
20+
21+
func getDescription() -> String {
22+
description
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
import XCTest
22
@testable import FunctionCalling_FirebaseVertexAI
3+
import FunctionCalling
34

45
final class FunctionCalling_FirebaseVertexAITests: XCTestCase {
5-
func testExample() throws {
6-
// XCTest Documentation
7-
// https://developer.apple.com/documentation/xctest
6+
@FunctionCalling(service: .claude)
7+
struct FunctionContainer {
8+
/// Return current weather of location that passed by the argument
9+
/// - Parameter location: location that I want to know how the weather
10+
/// - Returns: string of weather
11+
@CallableFunction
12+
func getWeather(location: String) -> String {
13+
return "Sunny"
14+
}
815

9-
// Defining Test Cases and Test Methods
10-
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
11-
}
16+
@CallableFunction
17+
func getStock(args: String) -> Int {
18+
return 0
19+
}
20+
}
21+
22+
func testConvertedResults() throws {
23+
guard let functions = FunctionContainer().firebaseVertexAITools.first?.functions else {
24+
XCTFail("Conainer should contain some functions")
25+
return
26+
}
27+
28+
XCTAssertEqual(functions.count, 2)
29+
30+
let getWeather = try XCTUnwrap(functions.first)
31+
XCTAssertEqual(getWeather.getName(), "getWeather")
32+
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")
33+
34+
let getStock = try XCTUnwrap(functions.last)
35+
XCTAssertEqual(getStock.getName(), "getStock")
36+
XCTAssertEqual(getStock.getDescription(), "")
37+
}
1238
}

0 commit comments

Comments
 (0)