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
@context = nil
end
|
Instance Method Details
#__getobj__ ⇒ Object
13
14
15
|
# File 'lib/active_agent/generation.rb', line 13
def __getobj__
@context ||= processed_agent.context
end
|
#__setobj__(context) ⇒ Object
17
18
19
|
# File 'lib/active_agent/generation.rb', line 17
def __setobj__(context)
@context = context
end
|
#context ⇒ Object
21
22
23
|
# File 'lib/active_agent/generation.rb', line 21
def context
__getobj__
end
|
#embed_later(options = {}) ⇒ Object
61
62
63
|
# File 'lib/active_agent/generation.rb', line 61
def embed_later(options = {})
enqueue_generation :embed_now, options
end
|
#embed_now ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/active_agent/generation.rb', line 53
def embed_now
processed_agent.handle_exceptions do
processed_agent.run_callbacks(:embedding) do
processed_agent.embed
end
end
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(:generation) 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(:generation) 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 || @context
end
|