File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,7 @@ def models
17
17
18
18
# Pulls the specified models from the Ollama API. If no models are specified, but there is a default model, it will pull that one.
19
19
# @parameter models [Array(String)] The names of the models to pull.
20
- def pull ( models )
21
- if models . empty?
22
- models = [ Async ::Ollama ::Client . default_model ]
23
- end
24
-
20
+ def pull ( models : [ Async ::Ollama ::MODEL ] )
25
21
Async ::Ollama ::Client . open do |client |
26
22
models . each do |model |
27
23
client . pull ( model ) do |response |
Original file line number Diff line number Diff line change 9
9
module Async
10
10
module Ollama
11
11
# Represents a generated response from the Ollama API.
12
- class Generate < Async ::REST ::Representation [ Wrapper ]
12
+ class Generate < Async ::REST ::Representation [ GenerateWrapper ]
13
13
# @returns [String | nil] The generated response, or nil if not present.
14
14
def response
15
15
self . value [ :response ]
Original file line number Diff line number Diff line change @@ -139,6 +139,24 @@ def parser_for(response)
139
139
content_type = response . headers [ "content-type" ]
140
140
media_type = content_type . split ( ";" ) . first
141
141
142
+ case media_type
143
+ when APPLICATION_JSON
144
+ return Async ::REST ::Wrapper ::JSON ::Parser
145
+ when APPLICATION_JSON_STREAM
146
+ return StreamingParser
147
+ end
148
+ end
149
+ end
150
+
151
+ # Wraps generate-specific HTTP responses for the Ollama API, selecting the appropriate parser.
152
+ class GenerateWrapper < Wrapper
153
+ # Selects the appropriate parser for the generate HTTP response.
154
+ # @parameter response [Protocol::HTTP::Response] The HTTP response object.
155
+ # @returns [Class] The parser class to use.
156
+ def parser_for ( response )
157
+ content_type = response . headers [ "content-type" ]
158
+ media_type = content_type . split ( ";" ) . first
159
+
142
160
case media_type
143
161
when APPLICATION_JSON
144
162
return Async ::REST ::Wrapper ::JSON ::Parser
You can’t perform that action at this time.
0 commit comments