Class: OxAiWorkers::Assistant::Coder

Inherits:
Object
  • Object
show all
Includes:
ModuleBase
Defined in:
lib/oxaiworkers/assistant/coder.rb

Instance Attribute Summary

Attributes included from ModuleBase

#iterator

Attributes included from LoadI18n

#locale

Instance Method Summary collapse

Methods included from ModuleBase

#add_response, #execute, #init_worker, #task=

Methods included from LoadI18n

#store_locale, #with_locale

Constructor Details

#initialize(delayed: false, model: nil, language: 'ruby') ⇒ Coder

Returns a new instance of Coder.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/oxaiworkers/assistant/coder.rb', line 8

def initialize(delayed: false, model: nil, language: 'ruby')
  store_locale
  @iterator = Iterator.new(
    worker: init_worker(delayed: delayed, model: model),
    role: format(I18n.t('oxaiworkers.assistant.coder.role'), language),
    tools: [Tool::Eval.new, Tool::FileSystem.new],
    locale: @locale,
    on_inner_monologue: ->(text:) { puts "monologue: #{text}".colorize(:yellow) },
    on_outer_voice: ->(text:) { puts "voice: #{text}".colorize(:green) },
    on_action_request: ->(text:) { puts "action: #{text}".colorize(:red) },
    on_summarize: ->(text:) { puts "summary: #{text}".colorize(:blue) }
  )
end

Instance Method Details

#language=(language) ⇒ Object



22
23
24
25
26
# File 'lib/oxaiworkers/assistant/coder.rb', line 22

def language=(language)
  with_locale do
    @iterator.role = format(I18n.t('oxaiworkers.assistant.coder.role'), language)
  end
end