Class: Askcii::ChatFactory
- Inherits:
-
Object
- Object
- Askcii::ChatFactory
- Defined in:
- lib/askcii/chat_factory.rb
Overview
Factory for creating chat instances (private or persistent)
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#private ⇒ Object
readonly
Returns the value of attribute private.
-
#session_context ⇒ Object
readonly
Returns the value of attribute session_context.
Instance Method Summary collapse
-
#create ⇒ RubyLLM::Chat
Creates and returns a chat instance.
-
#initialize(config:, private: false, session_context: nil) ⇒ ChatFactory
constructor
A new instance of ChatFactory.
-
#system_instruction ⇒ String
Gets the system instruction from config or uses default.
Constructor Details
#initialize(config:, private: false, session_context: nil) ⇒ ChatFactory
Returns a new instance of ChatFactory.
13 14 15 16 17 |
# File 'lib/askcii/chat_factory.rb', line 13 def initialize(config:, private: false, session_context: nil) @config = config @private = private @session_context = session_context || generate_session_id end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/askcii/chat_factory.rb', line 8 def config @config end |
#private ⇒ Object (readonly)
Returns the value of attribute private.
8 9 10 |
# File 'lib/askcii/chat_factory.rb', line 8 def private @private end |
#session_context ⇒ Object (readonly)
Returns the value of attribute session_context.
8 9 10 |
# File 'lib/askcii/chat_factory.rb', line 8 def session_context @session_context end |
Instance Method Details
#create ⇒ RubyLLM::Chat
Creates and returns a chat instance
21 22 23 |
# File 'lib/askcii/chat_factory.rb', line 21 def create private ? create_private_chat : create_persistent_chat end |
#system_instruction ⇒ String
Gets the system instruction from config or uses default
27 28 29 30 31 |
# File 'lib/askcii/chat_factory.rb', line 27 def system_instruction config[:system_instruction] || config['system_instruction'] || default_system_instruction end |