Class: RubyConversations::ConversationManager
- Inherits:
-
Object
- Object
- RubyConversations::ConversationManager
- Includes:
- RubyConversations::Concerns::ConversationChat, RubyConversations::Concerns::ConversationMessages, RubyConversations::Concerns::ConversationTemplates, RubyConversations::Concerns::LlmCredentials, RubyConversations::Concerns::MessageProcessing
- Defined in:
- lib/ruby_conversations/conversation_manager.rb
Overview
Manages a conversation, including message storage, relationships, and LLM integration.
Instance Attribute Summary collapse
-
#conversationable ⇒ Object
Returns the value of attribute conversationable.
-
#conversationable_id ⇒ Object
Returns the value of attribute conversationable_id.
-
#conversationable_type ⇒ Object
Returns the value of attribute conversationable_type.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#tool ⇒ Object
Returns the value of attribute tool.
-
#tools ⇒ Object
Returns the value of attribute tools.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Attributes included from RubyConversations::Concerns::ConversationChat
Instance Method Summary collapse
- #chat ⇒ Object
- #conversation_attributes_for_storage ⇒ Object
-
#initialize(attributes = {}) ⇒ ConversationManager
constructor
A new instance of ConversationManager.
- #model_identifier ⇒ Object
- #provider ⇒ Object
Methods included from RubyConversations::Concerns::MessageProcessing
Methods included from RubyConversations::Concerns::LlmCredentials
Methods included from RubyConversations::Concerns::ConversationTemplates
Methods included from RubyConversations::Concerns::ConversationMessages
#initialize_messages, #with_prompt, #with_prompts, #with_user_message
Methods included from RubyConversations::Concerns::ConversationChat
#call_llm, #enable_image_generation, #llm, #tool_calls?, #tool_names, #tools_configured?, #tools_required?, #validate_tool_calls
Constructor Details
#initialize(attributes = {}) ⇒ ConversationManager
Returns a new instance of ConversationManager.
18 19 20 21 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 18 def initialize(attributes = {}) setup_attributes(attributes) configure_llm_credentials end |
Instance Attribute Details
#conversationable ⇒ Object
Returns the value of attribute conversationable.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def conversationable @conversationable end |
#conversationable_id ⇒ Object
Returns the value of attribute conversationable_id.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def conversationable_id @conversationable_id end |
#conversationable_type ⇒ Object
Returns the value of attribute conversationable_type.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def conversationable_type @conversationable_type end |
#created_at ⇒ Object
Returns the value of attribute created_at.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def id @id end |
#messages ⇒ Object
Returns the value of attribute messages.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def @messages end |
#tool ⇒ Object
Returns the value of attribute tool.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def tool @tool end |
#tools ⇒ Object
Returns the value of attribute tools.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def tools @tools end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
15 16 17 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 15 def updated_at @updated_at end |
Instance Method Details
#chat ⇒ Object
23 24 25 26 27 28 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 23 def chat @chat ||= build_chat_with_caching rescue RubyLLM::ModelNotFoundError RubyLLM.models.refresh! @chat ||= build_chat_with_caching end |
#conversation_attributes_for_storage ⇒ Object
38 39 40 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 38 def conversation_attributes_for_storage { ai_conversation: base_attributes.merge(relationship_attributes).merge().compact } end |
#model_identifier ⇒ Object
30 31 32 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 30 def model_identifier @model_identifier ||= RubyConversations.configuration.default_llm_model end |
#provider ⇒ Object
34 35 36 |
# File 'lib/ruby_conversations/conversation_manager.rb', line 34 def provider @provider ||= RubyConversations.configuration.default_llm_provider end |