Class: ActiveAgent::Generation
- Inherits:
-
Delegator
- Object
- Delegator
- ActiveAgent::Generation
show all
- Defined in:
- lib/active_agent/generation.rb
Instance Method Summary
collapse
Constructor Details
#initialize(agent_class, action, *args) ⇒ Generation
Returns a new instance of Generation.
6
7
8
9
10
|
# File 'lib/active_agent/generation.rb', line 6
def initialize(agent_class, action, *args)
@agent_class, @action, @args = agent_class, action, args
@processed_agent = nil
@prompt_context = nil
end
|
Instance Method Details
#__getobj__ ⇒ Object
13
14
15
|
# File 'lib/active_agent/generation.rb', line 13
def __getobj__
@prompt_context ||= processed_agent.context
end
|
#__setobj__(prompt_context) ⇒ Object
17
18
19
|
# File 'lib/active_agent/generation.rb', line 17
def __setobj__(prompt_context)
@prompt_context = prompt_context
end
|
#context ⇒ Object
21
22
23
|
# File 'lib/active_agent/generation.rb', line 21
def context
__getobj__
end
|
#generate_later(options = {}) ⇒ Object
33
34
35
|
# File 'lib/active_agent/generation.rb', line 33
def generate_later(options = {})
enqueue_generation :generate_now, options
end
|
#generate_later!(options = {}) ⇒ Object
29
30
31
|
# File 'lib/active_agent/generation.rb', line 29
def generate_later!(options = {})
enqueue_generation :generate_now!, options
end
|
#generate_now ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/active_agent/generation.rb', line 45
def generate_now
processed_agent.handle_exceptions do
processed_agent.run_callbacks(:generate) do
processed_agent.perform_generation
end
end
end
|
#generate_now! ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/active_agent/generation.rb', line 37
def generate_now!
processed_agent.handle_exceptions do
processed_agent.run_callbacks(:generate) do
processed_agent..perform_generation
end
end
end
|
#processed? ⇒ Boolean
25
26
27
|
# File 'lib/active_agent/generation.rb', line 25
def processed?
@processed_agent || @prompt_context
end
|