Class: Async::Ollama::ChatWrapper

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/async/ollama/wrapper.rb

Overview

Wraps chat-specific HTTP responses for the Ollama API, selecting the appropriate parser.

Constant Summary

Constants inherited from Wrapper

Wrapper::APPLICATION_JSON, Wrapper::APPLICATION_JSON_STREAM

Instance Method Summary collapse

Methods inherited from Wrapper

#prepare_request

Instance Method Details

#parser_for(response) ⇒ Object

Selects the appropriate parser for the chat HTTP response.



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/async/ollama/wrapper.rb', line 156

def parser_for(response)
	content_type = response.headers["content-type"]
	media_type = content_type.split(";").first
	
	case media_type
	when APPLICATION_JSON
		return Async::REST::Wrapper::JSON::Parser
	when APPLICATION_JSON_STREAM
		return StreamingMessageParser
	end
end