Class: OmniAI::Chat::Message::Builder
- Inherits:
-
Object
- Object
- OmniAI::Chat::Message::Builder
- Defined in:
- lib/omniai/chat/message/builder.rb
Overview
Used to build a message.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Message
- #file(io, type) ⇒ File
-
#initialize(role: Role::USER) ⇒ Builder
constructor
A new instance of Builder.
- #text(value) ⇒ Text
- #url(uri, type) ⇒ URL
Constructor Details
#initialize(role: Role::USER) ⇒ Builder
17 18 19 20 |
# File 'lib/omniai/chat/message/builder.rb', line 17 def initialize(role: Role::USER) @role = role @content = [] end |
Class Method Details
.build(role:) {|builder| ... } ⇒ Message
10 11 12 13 14 |
# File 'lib/omniai/chat/message/builder.rb', line 10 def self.build(role:) builder = new(role:) yield(builder) builder.build end |
Instance Method Details
#build ⇒ Message
23 24 25 |
# File 'lib/omniai/chat/message/builder.rb', line 23 def build Message.new(content: @content, role: @role) end |
#file(io, type) ⇒ File
59 60 61 62 63 |
# File 'lib/omniai/chat/message/builder.rb', line 59 def file(io, type) File.new(io, type).tap do |file| @content << file end end |
#text(value) ⇒ Text
33 34 35 36 37 |
# File 'lib/omniai/chat/message/builder.rb', line 33 def text(value) Text.new(value).tap do |text| @content << text end end |
#url(uri, type) ⇒ URL
46 47 48 49 50 |
# File 'lib/omniai/chat/message/builder.rb', line 46 def url(uri, type) URL.new(uri, type).tap do |url| @content << url end end |