Class: GeminiCraft::PayloadBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gemini_craft/client.rb

Instance Method Summary collapse

Instance Method Details

#build(text, system_instruction, options, stream: false) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/gemini_craft/client.rb', line 168

def build(text, system_instruction, options, stream: false)
  payload = {
    contents: [
      {
        parts: [
          {
            text: text
          }
        ]
      }
    ]
  }

  if system_instruction
    payload[:system_instruction] = {
      parts: [
        {
          text: system_instruction
        }
      ]
    }
  end

  # Don't include stream flag in payload for SSE streaming
  # payload[:stream] = true if stream

  payload.merge!(options) if options && !options.empty?
  payload
end