Class: AnalyticalBrain::Tools::RenameSession
- Inherits:
-
Tools::Base
- Object
- Tools::Base
- AnalyticalBrain::Tools::RenameSession
- Defined in:
- lib/analytical_brain/tools/rename_session.rb
Overview
Renames the main session with an emoji and short descriptive name. Operates on the main session passed through the registry context, not on the phantom analytical brain session.
The analytical brain calls this when a conversation’s topic becomes clear or shifts significantly enough to warrant a new name.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(input) ⇒ String, Hash
-
#initialize(main_session:) ⇒ RenameSession
constructor
A new instance of RenameSession.
Methods inherited from Tools::Base
Constructor Details
#initialize(main_session:) ⇒ RenameSession
Returns a new instance of RenameSession.
35 36 37 |
# File 'lib/analytical_brain/tools/rename_session.rb', line 35 def initialize(main_session:, **) @main_session = main_session end |
Class Method Details
.description ⇒ Object
14 15 |
# File 'lib/analytical_brain/tools/rename_session.rb', line 14 def self.description = "Rename the conversation session. " \ "Use one emoji followed by 1-3 descriptive words." |
.input_schema ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/analytical_brain/tools/rename_session.rb', line 17 def self.input_schema { type: "object", properties: { emoji: { type: "string", description: "A single emoji representing the conversation topic" }, name: { type: "string", description: "1-3 word descriptive name for the session" } }, required: %w[emoji name] } end |
.tool_name ⇒ Object
12 |
# File 'lib/analytical_brain/tools/rename_session.rb', line 12 def self.tool_name = "rename_session" |
Instance Method Details
#execute(input) ⇒ String, Hash
42 43 44 45 46 47 48 49 |
# File 'lib/analytical_brain/tools/rename_session.rb', line 42 def execute(input) error = validate(input) return error if error full_name = build_name(input) @main_session.update!(name: full_name) "Session renamed to: #{full_name}" end |