Class: Foobara::Ai::AnswerBot::Ask
- Defined in:
- foobara-ai-1.0.4/src/foobara/ai/answer_bot/ask.rb
Constant Summary
Constants included from TruncatedInspect
Instance Attribute Summary collapse
-
#ai_command ⇒ Object
Returns the value of attribute ai_command.
-
#ai_service ⇒ Object
Returns the value of attribute ai_service.
-
#answer ⇒ Object
Returns the value of attribute answer.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #determine_ai_command ⇒ Object
- #determine_ai_service ⇒ Object
- #execute ⇒ Object
- #run_ai_service ⇒ Object
Methods inherited from Command
Methods included from TruncatedInspect
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Instance Attribute Details
#ai_command ⇒ Object
Returns the value of attribute ai_command.
29 30 31 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 29 def ai_command @ai_command end |
#ai_service ⇒ Object
Returns the value of attribute ai_service.
29 30 31 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 29 def ai_service @ai_service end |
#answer ⇒ Object
Returns the value of attribute answer.
29 30 31 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 29 def answer @answer end |
#response ⇒ Object
Returns the value of attribute response.
29 30 31 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 29 def response @response end |
Instance Method Details
#determine_ai_command ⇒ Object
35 36 37 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 35 def determine_ai_command self.ai_command = Foobara::Ai::AnswerBot::DomainMappers::ServiceToChatCompletionCommand.map!(ai_service) end |
#determine_ai_service ⇒ Object
31 32 33 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 31 def determine_ai_service self.ai_service = service || domain_map!(model, from: :model_enum) end |
#execute ⇒ Object
21 22 23 24 25 26 27 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 21 def execute determine_ai_service determine_ai_command run_ai_service answer end |
#run_ai_service ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'src/foobara/ai/answer_bot/ask.rb', line 39 def run_ai_service inputs = { question:, model: } if instructions inputs[:instructions] = instructions end inputs = domain_map!(inputs, to: ai_command) answer = run_subcommand!(ai_command, inputs) self.answer = domain_map!(answer, to: :string) end |