Class: Foobara::Ai::AnswerBot::Ask
- Defined in:
- foobara-ai-0.0.11/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.
Attributes included from CommandPatternImplementation::Concerns::Subcommands
Attributes included from CommandPatternImplementation::Concerns::Runtime
Attributes included from CommandPatternImplementation::Concerns::Errors
Attributes included from CommandPatternImplementation::Concerns::Inputs
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 Concern
foobara_class_methods_module_for, foobara_concern?, included
Methods included from CommandPatternImplementation::Concerns::Reflection
Methods included from CommandPatternImplementation::Concerns::DomainMappers
#domain_map, #domain_map!, #run_mapped_subcommand!
Methods included from CommandPatternImplementation::Concerns::Subcommands
#run_subcommand!, #subcommand?
Methods included from CommandPatternImplementation::Concerns::Entities
Methods included from CommandPatternImplementation::Concerns::Transactions
#auto_detect_current_transactions, #commit_transaction, #open_transaction, #opened_transactions, #relevant_entity_classes, #rollback_transaction, #transactions
Methods included from CommandPatternImplementation::Concerns::StateMachine
Methods included from CommandPatternImplementation::Concerns::Runtime
#halt!, #run, #run!, #run_execute, #succeed, #success?, #validate, #validate_records
Methods included from CommandPatternImplementation::Concerns::Errors
Methods included from CommandPatternImplementation::Concerns::Inputs
#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?
Methods included from TruncatedInspect
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs
Instance Attribute Details
#ai_command ⇒ Object
Returns the value of attribute ai_command.
29 30 31 |
# File 'foobara-ai-0.0.11/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 'foobara-ai-0.0.11/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 'foobara-ai-0.0.11/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 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/ask.rb', line 29 def response @response end |
Instance Method Details
#determine_ai_command ⇒ Object
35 36 37 |
# File 'foobara-ai-0.0.11/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 'foobara-ai-0.0.11/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 'foobara-ai-0.0.11/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 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/ask.rb', line 39 def run_ai_service inputs = { question:, model: } if instructions inputs[:instructions] = instructions end self.answer = run_mapped_subcommand!(ai_command, inputs) end |