Skip to content

Commit 30a93fb

Browse files
Updating Read me
1 parent 90fe830 commit 30a93fb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ An open-source Swift package that simplifies LLM message completions, inspired b
2020
- [Collaboration](#collaboration)
2121
- [OpenAI Azure](OpenAI Azure)
2222
- [OpenAI AIProxy](AIProxy)
23+
- [Gemini](Gemini)
2324

2425
## Description
2526

26-
Call different LLM APIs using the OpenAI format; currently supporting [OpenAI](https://github.com/jamesrochabrun/SwiftOpenAI) and [Anthropic](https://github.com/jamesrochabrun/SwiftAnthropic), with more models, including Gemini, coming soon.
27+
Call different LLM APIs using the OpenAI format; currently supporting [OpenAI](https://github.com/jamesrochabrun/SwiftOpenAI), [Anthropic](https://github.com/jamesrochabrun/SwiftAnthropic), and [Gemini](https://github.com/google-gemini/generative-ai-swift).
2728

2829
## Installation
2930

@@ -54,12 +55,13 @@ First, import the PolyAI package:
5455
import PolyAI
5556
```
5657

57-
Then, define the LLM configurations. Currently, OpenAI and Anthropic are supported:
58+
Then, define the LLM configurations. Currently, OpenAI, Anthropic and Gemini are supported:
5859

5960
```swift
6061
let openAIConfiguration: LLMConfiguration = .openAI(.api(key: "your_openai_api_key_here"))
6162
let anthropicConfiguration: LLMConfiguration = .anthropic(apiKey: "your_anthropic_api_key_here")
62-
let configurations = [openAIConfiguration, anthropicConfiguration]
63+
let geminiConfiguration: LLMConfiguration = .gemini(apiKey: "your_gemini_api_key_here")
64+
let configurations = [openAIConfiguration, anthropicConfiguration, geminiConfiguration]
6365
```
6466

6567
With the configurations set, initialize the service:
@@ -68,7 +70,7 @@ With the configurations set, initialize the service:
6870
let service = PolyAIServiceFactory.serviceWith(configurations)
6971
```
7072

71-
Now, you have access to both the OpenAI and Anthropic APIs in a single package, with Gemini coming soon! 🚀
73+
Now, you have access to OpenAI, Anthropic and Gemini APIs in a single package. 🚀
7274

7375
## Message
7476

@@ -88,6 +90,14 @@ let parameters: LLMParameter = .anthropic(model: .claude3Sonnet, messages: [.ini
8890
let stream = try await service.streamMessage(parameters)
8991
```
9092

93+
To interact with Gemini instead, all you need to do (again) is change just one line of code! 🔥
94+
95+
```swift
96+
let prompt = "How are you today?"
97+
let parameters: LLMParameter = .gemini(model: "gemini-pro", messages: [.init(role: .user, content: prompt)], maxTokens: 2000)
98+
let stream = try await service.streamMessage(parameters)
99+
```
100+
91101
## OpenAI Azure
92102

93103
To access the OpenAI API via Azure, you can use the following configuration setup.

0 commit comments

Comments
 (0)