File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 1
1
# Ollama Swift Client
2
2
3
- A Swift client library for interacting with the
3
+ A Swift client library for interacting with the
4
4
[ Ollama API] ( https://github.com/ollama/ollama/blob/main/docs/api.md ) .
5
5
6
6
## Requirements
@@ -21,11 +21,11 @@ Add the following to your `Package.swift` file:
21
21
22
22
## Usage
23
23
24
- > [ !NOTE]
25
- > The tests and example code for this library use the
24
+ > [ !NOTE]
25
+ > The tests and example code for this library use the
26
26
> [ llama3.2] ( https://ollama.com/library/llama3.2 ) model.
27
27
> Run the following command to download the model to run them yourself:
28
- >
28
+ >
29
29
> ```
30
30
> ollama pull llama3.2
31
31
> ```
53
53
model : " llama3.2" ,
54
54
prompt : " Tell me a joke about Swift programming." ,
55
55
options : [
56
- " temperature" : . number ( 0.7 ) ,
57
- " max_tokens" : . number ( 100 )
56
+ " temperature" : 0.7 ,
57
+ " max_tokens" : 100
58
58
]
59
59
)
60
60
print (response.response )
@@ -69,14 +69,12 @@ Generate a chat completion:
69
69
70
70
``` swift
71
71
do {
72
- let messages: [ChatMessage] = [
73
- .init (role : .system , content : " You are a helpful assistant." ),
74
- .init (role : .user , content : " In which city is Apple Inc. located?" )
75
- ]
76
-
77
72
let response = try await client.chat (
78
73
model : " llama3.2" ,
79
- messages : messages
74
+ messages : [
75
+ .system (" You are a helpful assistant." ),
76
+ .user (" In which city is Apple Inc. located?" )
77
+ ]
80
78
)
81
79
print (response.message .content )
82
80
} catch {
You can’t perform that action at this time.
0 commit comments