Class: Askcii::ChatSession
- Inherits:
-
Object
- Object
- Askcii::ChatSession
- Defined in:
- lib/askcii/chat_session.rb
Overview
Orchestrates chat execution with LLM providers
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.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#execute_chat(prompt, input = nil) ⇒ Object
Executes a chat session with the given prompt.
-
#initialize(config:, private: false, session_context: nil, verbose: false) ⇒ ChatSession
constructor
A new instance of ChatSession.
Constructor Details
#initialize(config:, private: false, session_context: nil, verbose: false) ⇒ ChatSession
Returns a new instance of ChatSession.
14 15 16 17 18 19 |
# File 'lib/askcii/chat_session.rb', line 14 def initialize(config:, private: false, session_context: nil, verbose: false) @config = config @private = private @session_context = session_context @verbose = verbose end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/askcii/chat_session.rb', line 8 def config @config end |
#private ⇒ Object (readonly)
Returns the value of attribute private.
8 9 10 |
# File 'lib/askcii/chat_session.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_session.rb', line 8 def session_context @session_context end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/askcii/chat_session.rb', line 8 def verbose @verbose end |
Instance Method Details
#execute_chat(prompt, input = nil) ⇒ Object
Executes a chat session with the given prompt
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/askcii/chat_session.rb', line 24 def execute_chat(prompt, input = nil) validate_prompt!(prompt) warn_large_input!(prompt, input) chat = create_chat full_prompt = build_prompt(prompt, input) verbose_output "Sending prompt (#{full_prompt.bytesize} bytes)..." # Execute the chat with streaming chat.ask(full_prompt) do |chunk| print chunk.content end puts '' # Ensure we end with a newline end |