Skip to content

Commit 5a93ee7

Browse files
committed
fix lint
1 parent a0572ca commit 5a93ee7

File tree

3 files changed

+58
-40
lines changed

3 files changed

+58
-40
lines changed

Package.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ let package = Package(
1313
// Products define the executables and libraries a package produces, making them visible to other packages.
1414
.library(
1515
name: "FunctionCalling-AIProxySwift",
16-
targets: ["FunctionCalling-AIProxySwift"]),
16+
targets: [
17+
"FunctionCalling-AIProxySwift"
18+
]
19+
)
1720
],
1821
dependencies: [
1922
.package(url: "https://github.com/fumito-ito/FunctionCalling", from: "0.4.0"),
@@ -30,7 +33,9 @@ let package = Package(
3033
]),
3134
.testTarget(
3235
name: "FunctionCalling-AIProxySwiftTests",
33-
dependencies: ["FunctionCalling-AIProxySwift"]
34-
),
36+
dependencies: [
37+
"FunctionCalling-AIProxySwift"
38+
]
39+
)
3540
]
3641
)

Sources/FunctionCalling-AIProxySwift/FunctionCalling_AIProxySwift.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import FunctionCalling
55
import AIProxy
66

77
extension ToolContainer {
8+
// swiftlint:disable:next line_length
89
// https://github.com/lzell/AIProxySwift?tab=readme-ov-file#how-to-use-openai-structured-outputs-json-schemas-in-a-tool-call
910
func toOpenAITools(strict: Bool = false) -> [OpenAIChatCompletionTool] {
1011
guard let allTools else { return [] }
@@ -18,7 +19,7 @@ extension ToolContainer {
1819
)
1920
}
2021
}
21-
22+
2223
// https://github.com/lzell/AIProxySwift?tab=readme-ov-file#how-to-use-streaming-tool-calls-with-anthropic
2324
func toAnthropicTools() -> [AnthropicTool] {
2425
guard let allTools else { return [] }
@@ -32,6 +33,7 @@ extension ToolContainer {
3233
}
3334
}
3435

36+
// swiftlint:disable:next line_length
3537
// https://github.com/lzell/AIProxySwift?tab=readme-ov-file#how-to-make-a-tool-call-request-with-llama-and-togetherai
3638
func toTogetherAITools() -> [TogetherAITool] {
3739
guard let allTools else { return [] }

Tests/FunctionCalling-AIProxySwiftTests/FunctionCalling_AIProxySwiftTests.swift renamed to Tests/FunctionCalling-AIProxySwiftTests/FunctionCallingAIProxySwiftTests.swift

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import XCTest
33
import FunctionCalling
44
import AIProxy
55

6-
final class FunctionCalling_AIProxySwiftTests: XCTestCase {
7-
6+
final class FunctionCallingAIProxySwiftTests: XCTestCase {
7+
88
var toolContainer: ToolContainer!
99

1010
struct MockToolContainer: ToolContainer {
11-
func execute(methodName name: String, parameters: [String : Any]) async -> String {
11+
func execute(methodName name: String, parameters: [String: Any]) async -> String {
1212
""
1313
}
14-
14+
1515
let allTools: [Tool]?
1616

1717
let allToolsJSONString: String = ""
@@ -29,18 +29,27 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
2929
inputSchema: .init(
3030
type: .object,
3131
properties: [
32-
"testParam": .init(type: .string, description: "A test parameter", enumValues: ["option1", "option2"])
32+
"testParam": .init(
33+
type: .string,
34+
description: "A test parameter",
35+
enumValues: [
36+
"option1",
37+
"option2"
38+
]
39+
)
3340
],
3441
requiredProperties: ["testParam"]
3542
)
3643
)
3744

3845
toolContainer = MockToolContainer(allTools: [tool])
3946
}
40-
47+
48+
// swiftlint:disable cyclomatic_complexity
49+
// swiftlint:disable function_body_length
4150
func testToOpenAITools() throws {
4251
let openAITools = toolContainer.toOpenAITools()
43-
52+
4453
XCTAssertEqual(openAITools.count, 1)
4554

4655
let openAITool = try XCTUnwrap(openAITools.first)
@@ -76,10 +85,10 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
7685
return
7786
}
7887

79-
let requiredProperties = required.compactMap { r in
80-
switch r {
81-
case .string(let p):
82-
return p
88+
let requiredProperties = required.compactMap { requiredProperty in
89+
switch requiredProperty {
90+
case .string(let propertyName):
91+
return propertyName
8392
default:
8493
return nil
8594
}
@@ -120,20 +129,20 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
120129

121130
XCTAssertEqual(enumValueArray.count, 2)
122131

123-
let enumValues = enumValueArray.compactMap { e in
124-
switch e {
125-
case .string(let v):
126-
return v
132+
let enumValues = enumValueArray.compactMap { enumValue in
133+
switch enumValue {
134+
case .string(let value):
135+
return value
127136
default:
128137
return nil
129138
}
130139
}
131140
XCTAssertEqual(enumValues, ["option1", "option2"])
132141
}
133-
142+
134143
func testToAnthropicTools() throws {
135144
let anthropicTools = toolContainer.toAnthropicTools()
136-
145+
137146
XCTAssertEqual(anthropicTools.count, 1)
138147
XCTAssertEqual(anthropicTools[0].name, "testTool")
139148
XCTAssertEqual(anthropicTools[0].description, "A test tool")
@@ -154,10 +163,10 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
154163
return
155164
}
156165

157-
let requiredProperties = required.compactMap { r in
158-
switch r {
159-
case .string(let p):
160-
return p
166+
let requiredProperties = required.compactMap { requiredProperty in
167+
switch requiredProperty {
168+
case .string(let propertyName):
169+
return propertyName
161170
default:
162171
return nil
163172
}
@@ -198,24 +207,24 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
198207

199208
XCTAssertEqual(enumValueArray.count, 2)
200209

201-
let enumValues = enumValueArray.compactMap { e in
202-
switch e {
203-
case .string(let v):
204-
return v
210+
let enumValues = enumValueArray.compactMap { enumValue in
211+
switch enumValue {
212+
case .string(let value):
213+
return value
205214
default:
206215
return nil
207216
}
208217
}
209218
XCTAssertEqual(enumValues, ["option1", "option2"])
210219
}
211-
220+
212221
func testToTogetherAITools() throws {
213222
let togetherAITools = toolContainer.toTogetherAITools()
214-
223+
215224
XCTAssertEqual(togetherAITools.count, 1)
216225
XCTAssertEqual(togetherAITools[0].function.name, "testTool")
217226
XCTAssertEqual(togetherAITools[0].function.description, "A test tool")
218-
227+
219228
// inputSchema
220229
let parameters = togetherAITools[0].function.parameters
221230

@@ -232,10 +241,10 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
232241
return
233242
}
234243

235-
let requiredProperties = required.compactMap { r in
236-
switch r {
237-
case .string(let p):
238-
return p
244+
let requiredProperties = required.compactMap { requiredProperty in
245+
switch requiredProperty {
246+
case .string(let propertyName):
247+
return propertyName
239248
default:
240249
return nil
241250
}
@@ -276,14 +285,16 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
276285

277286
XCTAssertEqual(enumValueArray.count, 2)
278287

279-
let enumValues = enumValueArray.compactMap { e in
280-
switch e {
281-
case .string(let v):
282-
return v
288+
let enumValues = enumValueArray.compactMap { enumValue in
289+
switch enumValue {
290+
case .string(let value):
291+
return value
283292
default:
284293
return nil
285294
}
286295
}
287296
XCTAssertEqual(enumValues, ["option1", "option2"])
288297
}
298+
// swiftlint:enable cyclomatic_complexity
299+
// swiftlint:enable function_body_length
289300
}

0 commit comments

Comments
 (0)