Class: ActiveAgent::Parameterized::DirectGeneration Private
- Inherits:
-
Generation
- Object
- Generation
- Generation
- ActiveAgent::Parameterized::DirectGeneration
- Defined in:
- lib/active_agent/concerns/parameterized.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A specialized generation class for direct prompt/embed calls without actions.
This class handles cases where you want to call Agent.prompt(…).generate_now or Agent.embed(…).generate_now without defining an action method.
Instance Method Summary collapse
-
#generate_now ⇒ Object
private
Override generate_now to route to correct method based on generation type.
-
#generate_now! ⇒ Object
private
Override generate_now! to route to correct method based on generation type.
-
#initialize(agent_class, generation_type, params, *args, **options) ⇒ DirectGeneration
constructor
private
A new instance of DirectGeneration.
-
#preview ⇒ String
private
Generates a preview based on generation type.
Methods inherited from Generation
#actions, #embed_later, #embed_now, #instructions, #message, #messages, #options, #processed?, #prompt_later, #prompt_now, #prompt_now!, #prompt_options, #prompt_preview
Constructor Details
#initialize(agent_class, generation_type, params, *args, **options) ⇒ DirectGeneration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DirectGeneration.
202 203 204 205 206 207 208 209 |
# File 'lib/active_agent/concerns/parameterized.rb', line 202 def initialize(agent_class, generation_type, params, *args, **) @generation_type = generation_type @direct_args = args @direct_options = # Use a synthetic action name that won't conflict with real methods super(agent_class, :"__direct_#{generation_type}__", params) end |
Instance Method Details
#generate_now ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override generate_now to route to correct method based on generation type
212 213 214 215 216 217 218 219 |
# File 'lib/active_agent/concerns/parameterized.rb', line 212 def generate_now case @generation_type when :prompt prompt_now when :embed end end |
#generate_now! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override generate_now! to route to correct method based on generation type
222 223 224 225 226 227 228 229 230 |
# File 'lib/active_agent/concerns/parameterized.rb', line 222 def generate_now! case @generation_type when :prompt prompt_now! when :embed # For embed, we don't have a separate embed_now! method, so use embed_now end end |
#preview ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generates a preview based on generation type.
236 237 238 239 240 241 242 243 |
# File 'lib/active_agent/concerns/parameterized.rb', line 236 def preview case @generation_type when :prompt prompt_preview when :embed raise NotImplementedError, "Embed previewing is not supported" end end |