Class: BxBuilderChain::QuestionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- BxBuilderChain::QuestionsController
- Defined in:
- lib/generators/bx_builder_chain/templates/app/controllers/bx_builder_chain/questions_controller.rb
Constant Summary collapse
- LLM_CLASS_NAME =
'BxBuilderChain::Llm::OpenAi'
- CLIENT_CLASS_NAME =
'BxBuilderChain::Vectorsearch::Pgvector'
Instance Method Summary collapse
-
#ask ⇒ Object
POST /bx_builder_chain/ask.
Instance Method Details
#ask ⇒ Object
POST /bx_builder_chain/ask
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/bx_builder_chain/templates/app/controllers/bx_builder_chain/questions_controller.rb', line 9 def ask service = QuestionAskingService.new( question: params[:question], user_groups: current_user_document_groups, # optional defaults to ['public'] client_class_name: CLIENT_CLASS_NAME, # optional defaults to 'BxBuilderChain::Vectorsearch::Pgvector' llm_class_name: LLM_CLASS_NAME, # optional defaults to 'BxBuilderChain::Llm::OpenAi' context_results: 10 # optional defaults to 6 ) response = service.ask if response[:error] render json: response, status: :bad_request else render json: response end end |