Class: Looped::Application
- Inherits:
-
Object
- Object
- Looped::Application
- Extended by:
- T::Sig
- Defined in:
- lib/looped/application.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#optimizer ⇒ Object
readonly
Returns the value of attribute optimizer.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(model: nil, judge_model: nil, reflection_model: nil, max_iterations: 10, optimizer_batch_size: 5, optimizer_interval: 60) ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
- #run_task(task:, context: '') ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(model: nil, judge_model: nil, reflection_model: nil, max_iterations: 10, optimizer_batch_size: 5, optimizer_interval: 60) ⇒ Application
Returns a new instance of Application.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/looped/application.rb', line 30 def initialize( model: nil, judge_model: nil, reflection_model: nil, max_iterations: 10, optimizer_batch_size: 5, optimizer_interval: 60 ) @state = T.let(State.new, State) @agent = T.let( Agent.new( model: model, max_iterations: max_iterations, judge_model: judge_model ), Agent ) @optimizer = T.let( Optimizer.new( state: @state, batch_size: optimizer_batch_size, check_interval: optimizer_interval, reflection_model: reflection_model ), Optimizer ) @running = T.let(false, T::Boolean) end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
12 13 14 |
# File 'lib/looped/application.rb', line 12 def agent @agent end |
#optimizer ⇒ Object (readonly)
Returns the value of attribute optimizer.
15 16 17 |
# File 'lib/looped/application.rb', line 15 def optimizer @optimizer end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
18 19 20 |
# File 'lib/looped/application.rb', line 18 def state @state end |
Instance Method Details
#run ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/looped/application.rb', line 60 def run @running = true puts puts "Type a coding task and press Enter. Type 'quit' to exit." puts "Type 'status' to see optimization status." puts "" Async do |task| # Start the optimizer in the background optimizer_task = task.async do @optimizer.start end # Run the interactive loop begin interactive_loop ensure @optimizer.stop optimizer_task.stop end end end |
#run_task(task:, context: '') ⇒ Object
85 86 87 |
# File 'lib/looped/application.rb', line 85 def run_task(task:, context: '') @agent.run(task: task, context: context) end |
#stop ⇒ Object
90 91 92 93 |
# File 'lib/looped/application.rb', line 90 def stop @running = false @optimizer.stop end |