Class: RailsOrchestrator::Response
- Inherits:
-
Object
- Object
- RailsOrchestrator::Response
- Defined in:
- lib/rails_orchestrator/response.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #content ⇒ Object
- #done? ⇒ Boolean
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
- #model ⇒ Object
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/rails_orchestrator/response.rb', line 7 def initialize(raw) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/rails_orchestrator/response.rb', line 5 def raw @raw end |
Instance Method Details
#content ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/rails_orchestrator/response.rb', line 11 def content # Ollama format if raw.key?("message") raw.dig("message", "content") # OpenAI-compatible format elsif raw.key?("choices") raw.dig("choices", 0, "message", "content") end end |
#done? ⇒ Boolean
25 26 27 |
# File 'lib/rails_orchestrator/response.rb', line 25 def done? raw["done"] == true end |
#model ⇒ Object
21 22 23 |
# File 'lib/rails_orchestrator/response.rb', line 21 def model raw["model"] end |