Class: Foobara::Ai::AnswerBot::GenerateNextMessage

Inherits:
Command
  • Object
show all
Defined in:
foobara-ai-1.0.4/src/foobara/ai/answer_bot/generate_next_message.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Command

install!

Methods included from TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Attribute Details

#ai_commandObject

Returns the value of attribute ai_command.



29
30
31
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 29

def ai_command
  @ai_command
end

#ai_serviceObject

Returns the value of attribute ai_service.



29
30
31
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 29

def ai_service
  @ai_service
end

#next_messageObject

Returns the value of attribute next_message.



29
30
31
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 29

def next_message
  @next_message
end

#responseObject

Returns the value of attribute response.



29
30
31
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 29

def response
  @response
end

Instance Method Details

#determine_ai_commandObject



35
36
37
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 35

def determine_ai_command
  self.ai_command = Foobara::Ai::AnswerBot::DomainMappers::ServiceToChatCompletionCommand.map!(ai_service)
end

#determine_ai_serviceObject



31
32
33
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 31

def determine_ai_service
  self.ai_service = service || domain_map!(model, from: :model_enum)
end

#executeObject



21
22
23
24
25
26
27
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 21

def execute
  determine_ai_service
  determine_ai_command
  run_ai_service

  next_message
end

#run_ai_serviceObject



39
40
41
42
43
44
45
# File 'src/foobara/ai/answer_bot/generate_next_message.rb', line 39

def run_ai_service
  inputs = { chat:, temperature:, model: }
  inputs = domain_map!(inputs, to: ai_command)
  next_message = run_subcommand!(ai_command, inputs)

  self.next_message = domain_map!(next_message, to: Types::Message)
end