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: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ An open-source Swift package designed for effortless interaction with OpenAI's p
17
17
-[Usage](#usage)
18
18
-[Azure OpenAI](#azure-openai)
19
19
-[AIProxy](#aiproxy)
20
+
-[Ollama](#ollama)
20
21
-[Collaboration](#collaboration)
21
22
22
23
## Description
@@ -3066,5 +3067,46 @@ Contributors of this library provide third party integrations as a convenience.
3066
3067
party's services are assumed at your own risk.
3067
3068
3068
3069
3070
+
## Ollama
3071
+
3072
+
Ollama now has built-in compatibility with the OpenAI [Chat Completions API](https://github.com/ollama/ollama/blob/main/docs/openai.md), making it possible to use more tooling and applications with Ollama locally.
3073
+
3074
+
<img width="783" alt="Screenshot 2024-06-24 at 11 52 35 PM" src="https://github.com/jamesrochabrun/SwiftOpenAI/assets/5378604/db2264cb-408c-471d-b65b-912795c082ed">
3075
+
3076
+
### ⚠️ Important
3077
+
3078
+
Remember that these models run locally, so you need to download them. If you want to use llama3, you can open the terminal and run the following command:
3079
+
3080
+
```python
3081
+
ollama pull llama3
3082
+
```
3083
+
3084
+
you can follow [Ollama documentation](https://github.com/ollama/ollama/blob/main/docs/openai.md) for more.
3085
+
3086
+
### How to use this models locally using SwiftOpenAI?
3087
+
3088
+
To use local models with an `OpenAIService` in your application, you need to provide a URL.
3089
+
3090
+
```swift
3091
+
let service = OpenAIServiceFactory.ollama(baseURL: "http://localhost:11434")
3092
+
```
3093
+
3094
+
Then you can use the completions API as follows:
3095
+
3096
+
```swift
3097
+
let prompt ="Tell me a joke"
3098
+
let parameters =ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .custom("llama3"))
3099
+
let chatCompletionObject = service.startStreamedChat(parameters: parameters)
0 commit comments