Class: WritersRoom::Actor
- Inherits:
-
RobotLab::Robot
- Object
- RobotLab::Robot
- WritersRoom::Actor
- Defined in:
- lib/writers_room/actor.rb
Overview
AI-powered Actor that uses RobotLab's template system, tools, and bus messaging to participate in multi-character scenes.
Follows the RobotLab example 16 Writer pattern:
- Uses template + context instead of inline heredoc prompts
- Equipped with tools (SpeakTool, ReadMemoryTool, etc.)
- Reacts to bus messages via on_message handler
- Resets chat before each message (shared memory is persistence)
Constant Summary collapse
- RECENT_DIALOG_LIMIT =
10
Instance Attribute Summary collapse
-
#character_info ⇒ Object
readonly
Returns the value of attribute character_info.
-
#character_name ⇒ Object
readonly
Returns the value of attribute character_name.
-
#display ⇒ Object
Returns the value of attribute display.
-
#room ⇒ Object
Returns the value of attribute room.
-
#scene_info ⇒ Object
readonly
Returns the value of attribute scene_info.
-
#shared_memory ⇒ Object
Returns the value of attribute shared_memory.
Instance Method Summary collapse
-
#disconnect ⇒ Object
Unsubscribe from the scene channel before disconnecting.
-
#initialize(character_info:, scene_info:, bus:, shared_memory: nil, display: nil, room: nil, config: nil) ⇒ Actor
constructor
Initialize an Actor with character information.
Constructor Details
#initialize(character_info:, scene_info:, bus:, shared_memory: nil, display: nil, room: nil, config: nil) ⇒ Actor
Initialize an Actor with character information.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/writers_room/actor.rb', line 34 def initialize(character_info:, scene_info:, bus:, shared_memory: nil, display: nil, room: nil, config: nil) @character_info = character_info @character_name = character_info[:name] || character_info["name"] @scene_info = scene_info @shared_memory = shared_memory @display = display @room = room @messages_processed = 0 validate_character_info! @actor_context = build_template_context super( name: @character_name.downcase.gsub(/\s+/, "_"), template: :actor_system, context: @actor_context, bus: bus, config: config, local_tools: build_tools ) subscribe_to_scene end |
Instance Attribute Details
#character_info ⇒ Object (readonly)
Returns the value of attribute character_info.
20 21 22 |
# File 'lib/writers_room/actor.rb', line 20 def character_info @character_info end |
#character_name ⇒ Object (readonly)
Returns the value of attribute character_name.
20 21 22 |
# File 'lib/writers_room/actor.rb', line 20 def character_name @character_name end |
#display ⇒ Object
Returns the value of attribute display.
21 22 23 |
# File 'lib/writers_room/actor.rb', line 21 def display @display end |
#room ⇒ Object
Returns the value of attribute room.
21 22 23 |
# File 'lib/writers_room/actor.rb', line 21 def room @room end |
#scene_info ⇒ Object (readonly)
Returns the value of attribute scene_info.
20 21 22 |
# File 'lib/writers_room/actor.rb', line 20 def scene_info @scene_info end |
#shared_memory ⇒ Object
Returns the value of attribute shared_memory.
21 22 23 |
# File 'lib/writers_room/actor.rb', line 21 def shared_memory @shared_memory end |
Instance Method Details
#disconnect ⇒ Object
Unsubscribe from the scene channel before disconnecting.
61 62 63 64 65 66 67 |
# File 'lib/writers_room/actor.rb', line 61 def disconnect if @bus && @scene_subscriber_id @bus.unsubscribe(:scene, @scene_subscriber_id) @scene_subscriber_id = nil end super end |