Class: Buble::GeminiResource
- Inherits:
-
Object
- Object
- Buble::GeminiResource
- Defined in:
- lib/buble/chat.rb
Instance Method Summary collapse
- #generate_content(model, body) ⇒ Object
-
#initialize(http) ⇒ GeminiResource
constructor
A new instance of GeminiResource.
- #stream_generate_content(model, body) ⇒ Object
- #stream_text(model, body) ⇒ Object
Constructor Details
#initialize(http) ⇒ GeminiResource
Returns a new instance of GeminiResource.
71 72 73 |
# File 'lib/buble/chat.rb', line 71 def initialize(http) @http = http end |
Instance Method Details
#generate_content(model, body) ⇒ Object
75 76 77 |
# File 'lib/buble/chat.rb', line 75 def generate_content(model, body) @http.request('POST', "/api/v1beta/models/#{HTTP.encode_model_path(model)}:generateContent", body: body) end |
#stream_generate_content(model, body) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/buble/chat.rb', line 79 def stream_generate_content(model, body) path = "/api/v1beta/models/#{HTTP.encode_model_path(model)}:streamGenerateContent" Streaming.events_from_lines( @http.stream_lines('POST', path, body: body) ) end |
#stream_text(model, body) ⇒ Object
86 87 88 |
# File 'lib/buble/chat.rb', line 86 def stream_text(model, body) Streaming.text_stream(stream_generate_content(model, body), :gemini) end |