Skip to content

Commit 9ed14ca

Browse files
committed
update readme
1 parent 45a85f2 commit 9ed14ca

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
11
# FunctionCalling-MacPaw-OpenAI
2-
Easy to use your Swift native functions for function calling with [MacPaw/OpenAI](https://github.com/MacPaw/OpenAI).
2+
3+
This library simplifies the integration of the [FunctionCalling](https://github.com/fumito-ito/FunctionCalling) macro into [MacPaw/OpenAI](https://github.com/MacPaw/OpenAI). By using this library, you can directly generate `Tool` objects from Swift native functions, which can then be specified as FunctionCalling when invoking VertexAI.
4+
5+
## Usage
6+
7+
```swift
8+
9+
import FunctionCalling
10+
import FunctionCalling_MacPaw_OpenAI
11+
import OpenAI
12+
13+
// MARK: Declare the container and functions for the tools to be called from FunctionCalling.
14+
15+
@FunctionCalling(service: .chatGPT)
16+
struct MyFunctionTools {
17+
@CallableFunction
18+
/// Get the current stock price for a given ticker symbol
19+
///
20+
/// - Parameter: The stock ticker symbol, e.g. GOOG for Google Inc.
21+
func getStockPrice(ticker: String) async throws -> String {
22+
// code to return stock price of passed ticker
23+
}
24+
}
25+
26+
// MARK: You can directly pass the tools generated from objects to the model in ChatQuery.
27+
let query = ChatQuery(
28+
model: .gpt3_5Turbo,
29+
messages: [.init(role: .user, content: "who are you")],
30+
tools: FunctionContainer().macPawOpenAITools
31+
)
32+
let result = try await openAI.chats(query: query)
33+
```
34+
35+
## Installation
36+
37+
### Swift Package Manager
38+
39+
```
40+
let package = Package(
41+
name: "MyPackage",
42+
products: [...],
43+
targets: [
44+
.target(
45+
"YouAppModule",
46+
dependencies: [
47+
.product(name: "FunctionCalling-MacPaw-OpenAI", package: "FunctionCalling-MacPaw-OpenAI")
48+
]
49+
)
50+
],
51+
dependencies: [
52+
.package(url: "https://github.com/FunctionCalling/FunctionCalling-MacPaw-OpenAI", from: "0.1.0")
53+
]
54+
)
55+
```
56+
57+
## Contributing
58+
59+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
60+
61+
Please make sure to update tests as appropriate.
62+
63+
## License
64+
65+
The MIT License

0 commit comments

Comments
 (0)