Skip to content

Commit 49e1929

Browse files
committed
add basic functions
1 parent d26e6a6 commit 49e1929

File tree

4 files changed

+162
-7
lines changed

4 files changed

+162
-7
lines changed

.gitignore

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/xcode,swift,swiftpackagemanager
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=xcode,swift,swiftpackagemanager
3+
4+
### Swift ###
15
# Xcode
26
#
37
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
48

59
## User settings
610
xcuserdata/
711

12+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
13+
*.xcscmblueprint
14+
*.xccheckout
15+
16+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
17+
build/
18+
DerivedData/
19+
*.moved-aside
20+
*.pbxuser
21+
!default.pbxuser
22+
*.mode1v3
23+
!default.mode1v3
24+
*.mode2v3
25+
!default.mode2v3
26+
*.perspectivev3
27+
!default.perspectivev3
28+
829
## Obj-C/Swift specific
930
*.hmap
1031

@@ -18,39 +39,36 @@ timeline.xctimeline
1839
playground.xcworkspace
1940

2041
# Swift Package Manager
21-
#
2242
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
2343
# Packages/
2444
# Package.pins
2545
# Package.resolved
2646
# *.xcodeproj
27-
#
2847
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
2948
# hence it is not needed unless you have added a package configuration file to your project
3049
# .swiftpm
3150

3251
.build/
3352

3453
# CocoaPods
35-
#
3654
# We recommend against adding the Pods directory to your .gitignore. However
3755
# you should judge for yourself, the pros and cons are mentioned at:
3856
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
39-
#
4057
# Pods/
41-
#
4258
# Add this line if you want to avoid checking in source code from the Xcode workspace
4359
# *.xcworkspace
4460

4561
# Carthage
46-
#
4762
# Add this line if you want to avoid checking in source code from Carthage dependencies.
4863
# Carthage/Checkouts
4964

5065
Carthage/Build/
5166

67+
# Accio dependency management
68+
Dependencies/
69+
.accio/
70+
5271
# fastlane
53-
#
5472
# It is recommended to not store the screenshots in the git repo.
5573
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
5674
# For more information about the recommended setup visit:
@@ -60,3 +78,33 @@ fastlane/report.xml
6078
fastlane/Preview.html
6179
fastlane/screenshots/**/*.png
6280
fastlane/test_output
81+
82+
# Code Injection
83+
# After new code Injection tools there's a generated folder /iOSInjectionProject
84+
# https://github.com/johnno1962/injectionforxcode
85+
86+
iOSInjectionProject/
87+
88+
### SwiftPackageManager ###
89+
Packages
90+
xcuserdata
91+
*.xcodeproj
92+
93+
94+
### Xcode ###
95+
96+
## Xcode 8 and earlier
97+
98+
### Xcode Patch ###
99+
*.xcodeproj/*
100+
!*.xcodeproj/project.pbxproj
101+
!*.xcodeproj/xcshareddata/
102+
!*.xcodeproj/project.xcworkspace/
103+
!*.xcworkspace/contents.xcworkspacedata
104+
/*.gcno
105+
**/xcshareddata/WorkspaceSettings.xcsettings
106+
107+
# End of https://www.toptal.com/developers/gitignore/api/xcode,swift,swiftpackagemanager
108+
109+
Package.resolved
110+
.swiftpm

Package.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// swift-tools-version: 5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "FunctionCalling-AnthropicSwiftSDK",
8+
platforms: [
9+
.iOS(.v17),
10+
.macOS(.v14)
11+
],
12+
products: [
13+
// Products define the executables and libraries a package produces, making them visible to other packages.
14+
.library(
15+
name: "FunctionCalling-AnthropicSwiftSDK",
16+
targets: ["FunctionCalling-AnthropicSwiftSDK"]),
17+
],
18+
dependencies: [
19+
.package(url: "https://github.com/FunctionCalling/FunctionCalling.git", from: "0.5.0"),
20+
.package(url: "https://github.com/fumito-ito/AnthropicSwiftSDK", from: "0.8.0")
21+
],
22+
targets: [
23+
// Targets are the basic building blocks of a package, defining a module or a test suite.
24+
// Targets can depend on other targets in this package and products from dependencies.
25+
.target(
26+
name: "FunctionCalling-AnthropicSwiftSDK",
27+
dependencies: [
28+
.product(name: "FunctionCalling", package: "FunctionCalling"),
29+
.product(name: "AnthropicSwiftSDK", package: "AnthropicSwiftSDK")
30+
]
31+
),
32+
.testTarget(
33+
name: "FunctionCalling-AnthropicSwiftSDKTests",
34+
dependencies: ["FunctionCalling-AnthropicSwiftSDK"]
35+
),
36+
]
37+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// The Swift Programming Language
2+
// https://docs.swift.org/swift-book
3+
4+
import FunctionCalling
5+
import AnthropicSwiftSDK
6+
7+
extension ToolContainer {
8+
/// Converted tools for [AnthropicSwiftSDK](https://github.com/fumito-ito/AnthropicSwiftSDK)
9+
public var anthropicSwiftTools: [AnthropicSwiftSDK.Tool]? {
10+
guard let allTools else {
11+
return nil
12+
}
13+
14+
return allTools.map { $0.toAnthropicSwiftTool }
15+
}
16+
}
17+
18+
extension FunctionCalling.Tool {
19+
var toAnthropicSwiftTool: AnthropicSwiftSDK.Tool {
20+
AnthropicSwiftSDK
21+
.Tool
22+
.function(
23+
.init(
24+
name: name,
25+
description: description,
26+
inputSchema: inputSchema.toAnthropicSwiftInputSchema
27+
)
28+
)
29+
}
30+
}
31+
32+
extension FunctionCalling.InputSchema {
33+
var toAnthropicSwiftInputSchema: AnthropicSwiftSDK.InputSchema {
34+
AnthropicSwiftSDK.InputSchema(
35+
type: type.toAnthropicSwiftSchemaType,
36+
format: format,
37+
description: description ?? "",
38+
nullable: nullable,
39+
enumValues: enumValues,
40+
items: items?.toAnthropicSwiftInputSchema,
41+
properties: properties?.mapValues { $0.toAnthropicSwiftInputSchema },
42+
requiredProperties: requiredProperties
43+
)
44+
}
45+
}
46+
47+
extension FunctionCalling.InputSchema.DataType {
48+
var toAnthropicSwiftSchemaType: AnthropicSwiftSDK.InputSchema.SchemaType {
49+
switch self {
50+
case .string:
51+
return .string
52+
case .number:
53+
return .number
54+
case .integer:
55+
return .integer
56+
case .boolean:
57+
return .boolean
58+
case .array:
59+
return .arrray
60+
case .object:
61+
return .object
62+
}
63+
}
64+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Testing
2+
@testable import FunctionCalling_AnthropicSwiftSDK
3+
4+
@Test func example() async throws {
5+
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
6+
}

0 commit comments

Comments
 (0)