Class: Observ::Generators::InstallChatGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Observ::Generators::InstallChatGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/observ/install_chat/install_chat_generator.rb
Overview
Generator for installing Observ chat/agent testing feature
This generator enhances RubyLLM infrastructure with Observ-specific agent capabilities and observability features.
Prerequisites:
- RubyLLM gem installed (gem 'ruby_llm')
- rails generate ruby_llm:install (run first)
- rails db:migrate
- rails ruby_llm:load_models
Usage:
rails generate observ:install:chat
rails generate observ:install:chat --skip-tools
rails generate observ:install:chat --skip-migrations
Instance Method Summary collapse
- #add_phase_tracking ⇒ Object
- #check_prerequisites ⇒ Object
- #create_agent_infrastructure ⇒ Object
- #create_example_agent ⇒ Object
- #create_initializer ⇒ Object
- #create_job ⇒ Object
- #create_migrations ⇒ Object
- #create_tools ⇒ Object
- #enhance_models ⇒ Object
- #show_post_install_instructions ⇒ Object
Instance Method Details
#add_phase_tracking ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 144 def add_phase_tracking return unless [:with_phase_tracking] say "Adding phase tracking support...", :cyan say "-" * 80, :cyan # Call the add_phase_tracking generator generate "observ:add_phase_tracking" say "\n" end |
#check_prerequisites ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 48 def check_prerequisites say "\n" say "=" * 80, :cyan say "Observ Chat Feature Installation", :cyan say "=" * 80, :cyan say "\n" check_ruby_llm_gem check_ruby_llm_models_installed end |
#create_agent_infrastructure ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 86 def create_agent_infrastructure say "Creating agent infrastructure...", :cyan say "-" * 80, :cyan template "agents/base_agent.rb.tt", "app/agents/base_agent.rb" say " ✓ Created BaseAgent", :green say " ℹ AgentProvider is now available as Observ::AgentProvider (no generation needed)", :yellow say " ℹ AgentSelectable is now available as Observ::AgentSelectable (no generation needed)", :yellow say " ℹ PromptManagement is now available as Observ::PromptManagement (no generation needed)", :yellow say "\n" end |
#create_example_agent ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 99 def create_example_agent say "Creating example agent...", :cyan say "-" * 80, :cyan template "agents/simple_agent.rb.tt", "app/agents/simple_agent.rb" say " ✓ Created SimpleAgent", :green say "\n" end |
#create_initializer ⇒ Object
134 135 136 137 138 139 140 141 142 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 134 def create_initializer say "Creating observability initializer...", :cyan say "-" * 80, :cyan template "initializers/observability.rb.tt", "config/initializers/observability.rb" say " ✓ Created observability initializer (debug logging enabled)", :green say "\n" end |
#create_job ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 109 def create_job return if [:skip_job] say "Creating ChatResponseJob...", :cyan say "-" * 80, :cyan template "jobs/chat_response_job.rb.tt", "app/jobs/chat_response_job.rb" say " ✓ Created ChatResponseJob", :green say "\n" end |
#create_migrations ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 59 def create_migrations return if [:skip_migrations] say "Creating Observ-specific migrations...", :cyan say "-" * 80, :cyan migration_template "migrations/add_agent_class_name.rb.tt", "db/migrate/add_agent_class_name_to_chats.rb" migration_template "migrations/add_observability_session_id.rb.tt", "db/migrate/add_observability_session_id_to_chats.rb" say " ✓ Created agent_class_name migration", :green say " ✓ Created observability_session_id migration", :green say "\n" end |
#create_tools ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 121 def create_tools return if [:skip_tools] say "Creating tool classes...", :cyan say "-" * 80, :cyan template "tools/think_tool.rb.tt", "app/tools/think_tool.rb" say " ✓ Created ThinkTool (basic example)", :green say " ℹ For advanced tools (web search, etc.), see documentation", :yellow say "\n" end |
#enhance_models ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 76 def enhance_models say "Enhancing RubyLLM models with Observ functionality...", :cyan say "-" * 80, :cyan enhance_chat_model say "\n" end |
#show_post_install_instructions ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/generators/observ/install_chat/install_chat_generator.rb', line 156 def show_post_install_instructions say "\n" say "=" * 80, :green say "Observ Chat Feature Installation Complete!", :green say "=" * 80, :green say "\n" say "Next steps:", :cyan say "\n" say "1. Run migrations:", :cyan say " rails db:migrate", :white say "\n" say "2. Start your Rails server and visit:", :cyan say " http://localhost:3000/observ/chats", :white say "\n" say "3. Create your first agent by extending BaseAgent:", :cyan say " See app/agents/simple_agent.rb for an example", :white say "\n" unless [:with_phase_tracking] say "Optional: Add phase tracking for multi-phase agents:", :cyan say " rails generate observ:add_phase_tracking", :white say "\n" end say "Documentation:", :cyan say " • Agent development: observ/docs/AGENT_DEVELOPMENT.md", :white say " • Tool development: observ/docs/TOOL_DEVELOPMENT.md", :white say "\n" end |