You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Examples/SwiftOpenAIExample/SwiftOpenAIExample/ChatStreamFluidConversationDemo/ChatFluidConversationProvider.swift
+2-2
Original file line number
Diff line number
Diff line change
@@ -63,12 +63,12 @@ import SwiftOpenAI
63
63
// This information is essential for maintaining context in the conversation and for updating
64
64
// the chat UI with proper role attributions for each message.
[Ollama OpenAI compatibility blog post.](https://ollama.com/blog/openai-compatibility)
3264
+
Gemini is now accessible from the OpenAI Library. Announcement .
3265
+
`SwiftOpenAI` support all OpenAI endpoints, however Please refer to Gemini documentation to understand which API's are currently compatible'
3240
3266
3241
-
### Notes
3267
+
Gemini is now accessible through the OpenAI Library. See the announcement [here](https://developers.googleblog.com/en/gemini-is-now-accessible-from-the-openai-library/).
3268
+
SwiftOpenAI supports all OpenAI endpoints. However, please refer to the [Gemini documentation](https://ai.google.dev/gemini-api/docs/openai) to understand which APIs are currently compatible."
3242
3269
3243
-
You can also use this service constructor to provide any URL or apiKey if you need.
3270
+
3271
+
You can instantiate a `OpenAIService` using your Gemini token like this...
3244
3272
3245
3273
```swift
3246
-
let service = OpenAIServiceFactory.service(apiKey: "YOUR_API_KEY", baseURL: "http://localhost:11434")
3274
+
let geminiAPIKey ="your_api_key"
3275
+
let baseURL ="https://generativelanguage.googleapis.com"
3276
+
let version ="v1beta"
3277
+
3278
+
let service = OpenAIServiceFactory.service(
3279
+
apiKey: apiKey,
3280
+
overrideBaseURL: baseURL,
3281
+
overrideVersion: version)
3247
3282
```
3248
3283
3284
+
You can now create a chat request using the .custom model parameter and pass the model name as a string.
3285
+
3286
+
```swift
3287
+
let parameters =ChatCompletionParameters(
3288
+
messages: [.init(
3289
+
role: .user,
3290
+
content: content)],
3291
+
model: .custom("gemini-1.5-flash"))
3292
+
3293
+
let stream =tryawait service.startStreamedChat(parameters: parameters)
3294
+
```
3249
3295
3250
3296
## Collaboration
3251
3297
Open a PR forany proposed change pointing it to `main` branch. Unit tests are highly appreciated ❤️
0 commit comments