Class: Langchain::Assistant::Messages::Base
- Inherits:
-
Object
- Object
- Langchain::Assistant::Messages::Base
- Defined in:
- lib/langchain/assistant/messages/base.rb
Direct Known Subclasses
AnthropicMessage, GoogleGeminiMessage, MistralAIMessage, OllamaMessage, OpenAIMessage
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#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
- #image ⇒ Object
-
#llm? ⇒ Boolean
Check if the message came from an LLM.
-
#standard_role ⇒ Symbol
Returns the standardized role symbol based on the specific role methods.
-
#system? ⇒ Boolean
Check if the message is a system prompt.
-
#tool? ⇒ Boolean
Check if the message is a tool call.
-
#user? ⇒ Boolean
Check if the message came from a user.
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/langchain/assistant/messages/base.rb', line 7 def content @content end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
7 8 9 |
# File 'lib/langchain/assistant/messages/base.rb', line 7 def image_url @image_url end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
7 8 9 |
# File 'lib/langchain/assistant/messages/base.rb', line 7 def role @role end |
#tool_call_id ⇒ Object (readonly)
Returns the value of attribute tool_call_id.
7 8 9 |
# File 'lib/langchain/assistant/messages/base.rb', line 7 def tool_call_id @tool_call_id end |
#tool_calls ⇒ Object (readonly)
Returns the value of attribute tool_calls.
7 8 9 |
# File 'lib/langchain/assistant/messages/base.rb', line 7 def tool_calls @tool_calls end |
Instance Method Details
#image ⇒ Object
54 55 56 |
# File 'lib/langchain/assistant/messages/base.rb', line 54 def image image_url ? Utils::ImageWrapper.new(image_url) : nil end |
#llm? ⇒ Boolean
Check if the message came from an LLM
23 24 25 |
# File 'lib/langchain/assistant/messages/base.rb', line 23 def llm? raise NotImplementedError, "Class #{self.class.name} must implement the method 'llm?'" end |
#standard_role ⇒ Symbol
Returns the standardized role symbol based on the specific role methods
44 45 46 47 48 49 50 51 52 |
# File 'lib/langchain/assistant/messages/base.rb', line 44 def standard_role return :user if user? return :llm if llm? return :tool if tool? return :system if system? # TODO: Should we return :unknown or raise an error? :unknown end |
#system? ⇒ Boolean
Check if the message is a system prompt
37 38 39 |
# File 'lib/langchain/assistant/messages/base.rb', line 37 def system? raise NotImplementedError, "Class #{self.class.name} must implement the method 'system?'" end |
#tool? ⇒ Boolean
Check if the message is a tool call
30 31 32 |
# File 'lib/langchain/assistant/messages/base.rb', line 30 def tool? raise NotImplementedError, "Class #{self.class.name} must implement the method 'tool?'" end |
#user? ⇒ Boolean
Check if the message came from a user
16 17 18 |
# File 'lib/langchain/assistant/messages/base.rb', line 16 def user? role == "user" end |