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
/// Establishes an asynchronous stream for chat responses from the Ollama API, based on the provided data.
12
+
/// Starts a stream for chat responses from the Ollama API.
13
13
///
14
-
/// This method sets up a streaming connection using Swift's concurrency features, allowing for real-time data handling as chat responses are generated by the Ollama API.
15
-
///
16
-
/// Example usage
17
-
///
18
-
/// ```swift
19
-
/// let ollamaKit = OllamaKit()
20
-
/// let chatData = OKChatRequestData(/* parameters */)
21
-
///
22
-
/// Task {
23
-
/// do {
24
-
/// for try await response in ollamaKit.chat(data: chatData) {
25
-
/// // Handle each chat response
26
-
/// }
27
-
/// } catch {
28
-
/// // Handle error
29
-
/// }
30
-
/// }
31
-
/// ```
32
-
///
33
-
/// Example usage with tools
14
+
/// This method allows real-time handling of chat responses using Swift's concurrency.
34
15
///
16
+
/// Example usage:
35
17
/// ```swift
36
18
/// let ollamaKit = OllamaKit()
37
19
/// let chatData = OKChatRequestData(
38
-
/// /* parameters */,
20
+
/// model: "example-model",
21
+
/// messages: [
22
+
/// .user("What's the weather like in Tokyo?")
23
+
/// ],
39
24
/// tools: [
40
-
/// .object([
41
-
/// "type": .string("function"),
42
-
/// "function": .object([
43
-
/// "name": .string("get_current_weather"),
44
-
/// "description": .string("Get the current weather for a location"),
45
-
/// "parameters": .object([
46
-
/// "type": .string("object"),
47
-
/// "properties": .object([
48
-
/// "location": .object([
49
-
/// "type": .string("string"),
50
-
/// "description": .string("The location to get the weather for, e.g. San Francisco, CA")
51
-
/// ]),
52
-
/// "format": .object([
53
-
/// "type": .string("string"),
54
-
/// "description": .string("The format to return the weather in, e.g. 'celsius' or 'fahrenheit'"),
/// Establishes a Combine publisher for streaming chat responses from the Ollama API, based on the provided data.
113
-
///
114
-
/// This method sets up a streaming connection using the Combine framework, facilitating real-time data handling as chat responses are generated by the Ollama API.
69
+
/// Publishes a stream of chat responses from the Ollama API using Combine.
115
70
///
116
-
/// Example usage
117
-
///
118
-
/// ```swift
119
-
/// let ollamaKit = OllamaKit()
120
-
/// let chatData = OKChatRequestData(/* parameters */)
121
-
///
122
-
/// ollamaKit.chat(data: chatData)
123
-
/// .sink(receiveCompletion: { completion in
124
-
/// // Handle completion or error
125
-
/// }, receiveValue: { chatResponse in
126
-
/// // Handle each chat response
127
-
/// })
128
-
/// .store(in: &cancellables)
129
-
/// ```
130
-
///
131
-
/// Example usage with tools
71
+
/// Enables real-time data handling through Combine's reactive streams.
132
72
///
73
+
/// Example usage:
133
74
/// ```swift
134
75
/// let ollamaKit = OllamaKit()
135
76
/// let chatData = OKChatRequestData(
136
-
/// /* parameters */,
77
+
/// model: "example-model",
78
+
/// messages: [
79
+
/// .user("What's the weather like in Tokyo?")
80
+
/// ],
137
81
/// tools: [
138
-
/// .object([
139
-
/// "type": .string("function"),
140
-
/// "function": .object([
141
-
/// "name": .string("get_current_weather"),
142
-
/// "description": .string("Get the current weather for a location"),
143
-
/// "parameters": .object([
144
-
/// "type": .string("object"),
145
-
/// "properties": .object([
146
-
/// "location": .object([
147
-
/// "type": .string("string"),
148
-
/// "description": .string("The location to get the weather for, e.g. San Francisco, CA")
149
-
/// ]),
150
-
/// "format": .object([
151
-
/// "type": .string("string"),
152
-
/// "description": .string("The format to return the weather in, e.g. 'celsius' or 'fahrenheit'"),
0 commit comments