Class: Foobara::Ai::AnswerBot::ListModels
- Defined in:
- foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb
Constant Summary collapse
- LIST_COMMANDS =
AI_SERVICES.keys.map do |service| Foobara::Ai::AnswerBot::DomainMappers::ServiceToListModelsCommand.map!(service) end
Constants included from TruncatedInspect
Instance Attribute Summary collapse
-
#models ⇒ Object
Returns the value of attribute models.
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
- #execute ⇒ Object
- #map_to_foobara_models ⇒ Object
- #run_each_list_command_and_collect_models ⇒ Object
- #service_models ⇒ Object
- #sort_models ⇒ 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
Methods included from NestedTransactionable
#auto_detect_current_transactions, #commit_transaction, #commit_transaction_if_open, #open_transaction, #opened_transactions, #relevant_entity_classes, relevant_entity_classes_for_type, #relevant_entity_classes_for_type, #rollback_transaction, #transactions, #use_transaction
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
#models ⇒ Object
Returns the value of attribute models.
30 31 32 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb', line 30 def models @models end |
Instance Method Details
#execute ⇒ Object
[View source]
18 19 20 21 22 23 24 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb', line 18 def execute run_each_list_command_and_collect_models sort_models models end |
#map_to_foobara_models ⇒ Object
[View source]
40 41 42 43 44 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb', line 40 def self.models = service_models.map do |model| domain_map!(model, to: Types::Model) end end |
#run_each_list_command_and_collect_models ⇒ Object
[View source]
32 33 34 35 36 37 38 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb', line 32 def run_each_list_command_and_collect_models threads = LIST_COMMANDS.map do |list_command| Thread.new { service_models.concat(run_subcommand!(list_command)) } end self.models = threads.each(&:join).map(&:value) end |
#service_models ⇒ Object
[View source]
26 27 28 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb', line 26 def service_models @service_models ||= [] end |
#sort_models ⇒ Object
[View source]
46 47 48 49 50 |
# File 'foobara-ai-0.0.11/src/foobara/ai/answer_bot/list_models.rb', line 46 def sort_models models.sort_by! do |model| [model.service, model.id] end end |