Class: LLM::Multipart
- Inherits:
-
Object
- Object
- LLM::Multipart
- Defined in:
- lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb
Instance Attribute Summary collapse
- #boundary ⇒ String readonly
Instance Method Summary collapse
-
#body ⇒ String
Returns the multipart request body.
-
#content_type ⇒ String
Returns the multipart content type.
- #initialize(params) ⇒ LLM::Multipart constructor
Constructor Details
#initialize(params) ⇒ LLM::Multipart
17 18 19 20 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb', line 17 def initialize(params) @boundary = "BOUNDARY__#{SecureRandom.hex(16)}" @params = params end |
Instance Attribute Details
#boundary ⇒ String (readonly)
11 12 13 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb', line 11 def boundary @boundary end |
Instance Method Details
#body ⇒ String
Returns the multipart request body
32 33 34 35 36 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb', line 32 def body io = StringIO.new("".b) [*parts, StringIO.new("--#{@boundary}--\r\n".b)].each { IO.copy_stream(_1.tap(&:rewind), io) } io.tap(&:rewind) end |
#content_type ⇒ String
Returns the multipart content type
25 26 27 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb', line 25 def content_type "multipart/form-data; boundary=#{@boundary}" end |