Class: Protege::ModelMessage
- Inherits:
-
Data
- Object
- Data
- Protege::ModelMessage
- Defined in:
- lib/protege/types/model_message.rb
Overview
One normalized message in a chat-completions conversation — a role plus its content (one or more
content parts) and optional tool correlation. This is the pipeline-wide currency the model layer
speaks: providers serialize it to the wire (+Inference::Provider::Request#to_wire+), the harness
threads it through a run, and resolvers build it (via Resolver#message) to contribute context. It
lives here at the top level beside the content parts it carries (+TextPart+ / ImagePart /
DocumentPart) rather than inside Inference, because — like them — it is ownerless currency every
layer constructs and reads, not any one layer's private type. (It cannot be Protege::Message: that
name is the stored-email ActiveRecord model.)
role and content are always required. The tool-correlation fields are optional: tool_call_id
is meaningful only when role is :tool (it correlates a tool result back to the call);
tool_calls is meaningful only when role is :assistant and the model is requesting tool
execution.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#tool_call_id ⇒ Object
readonly
Returns the value of attribute tool_call_id.
-
#tool_calls ⇒ Object
readonly
Returns the value of attribute tool_calls.
Instance Method Summary collapse
-
#initialize(role:, content:, tool_call_id: nil, tool_calls: nil) ⇒ ModelMessage
constructor
A new instance of ModelMessage.
-
#parts ⇒ Array<TextPart>
Return content as a normalized parts array.
Constructor Details
#initialize(role:, content:, tool_call_id: nil, tool_calls: nil) ⇒ ModelMessage
Returns a new instance of ModelMessage.
27 28 29 |
# File 'lib/protege/types/model_message.rb', line 27 def initialize(role:, content:, tool_call_id: nil, tool_calls: nil) super end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content
17 18 19 |
# File 'lib/protege/types/model_message.rb', line 17 def content @content end |
#role ⇒ Object (readonly)
Returns the value of attribute role
17 18 19 |
# File 'lib/protege/types/model_message.rb', line 17 def role @role end |
#tool_call_id ⇒ Object (readonly)
Returns the value of attribute tool_call_id
17 18 19 |
# File 'lib/protege/types/model_message.rb', line 17 def tool_call_id @tool_call_id end |
#tool_calls ⇒ Object (readonly)
Returns the value of attribute tool_calls
17 18 19 |
# File 'lib/protege/types/model_message.rb', line 17 def tool_calls @tool_calls end |