Class: Tama::Agentic::MessageParams
- Inherits:
-
Data
- Object
- Data
- Tama::Agentic::MessageParams
- Defined in:
- lib/tama/agentic/message_params.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(recipient:, identifier:, content:, index:, author:, thread:, klass: "user-message") ⇒ MessageParams
constructor
A new instance of MessageParams.
- #to_h ⇒ Object
Constructor Details
#initialize(recipient:, identifier:, content:, index:, author:, thread:, klass: "user-message") ⇒ MessageParams
Returns a new instance of MessageParams.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tama/agentic/message_params.rb', line 6 def initialize(recipient:, identifier:, content:, index:, author:, thread:, klass: "user-message") Params.require_string!({"recipient" => recipient}, "recipient") Params.require_string!({"class" => klass}, "class") Params.require_string!({"identifier" => identifier}, "identifier") Params.require_string!({"content" => content}, "content") unless index.is_a?(Integer) raise Error::ValidationError.new("index is required", errors: {index: "must be an integer"}) end raise Error::ValidationError, "author is invalid" unless .is_a?(Author) raise Error::ValidationError, "thread is invalid" unless thread.is_a?(Thread) super end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def @author end |
#content ⇒ Object (readonly)
Returns the value of attribute content
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def content @content end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def identifier @identifier end |
#index ⇒ Object (readonly)
Returns the value of attribute index
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def index @index end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def klass @klass end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def recipient @recipient end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread
5 6 7 |
# File 'lib/tama/agentic/message_params.rb', line 5 def thread @thread end |
Class Method Details
.parse(value) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tama/agentic/message_params.rb', line 20 def self.parse(value) data = Params.hash(value, "message") new( recipient: data["recipient"], klass: data.fetch("class", "user-message"), identifier: data["identifier"], content: data["content"], index: data["index"], author: Author.parse(data["author"]), thread: Thread.parse(data["thread"]) ) end |
Instance Method Details
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tama/agentic/message_params.rb', line 33 def to_h { "recipient" => recipient, "class" => klass, "identifier" => identifier, "content" => content, "index" => index, "author" => .to_h, "thread" => thread.to_h } end |