Class: RailsLLM::AgentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RailsLLM::AgentsController
- Includes:
- ActionController::Live
- Defined in:
- app/controllers/rails_llm/agents_controller.rb
Instance Method Summary collapse
Instance Method Details
#ask ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/rails_llm/agents_controller.rb', line 27 def ask prompt = params[:prompt] return head(:unprocessable_entity) if prompt.blank? response.headers["Content-Type"] = "application/x-ndjson; charset=utf-8" response.headers["Cache-Control"] = "no-cache" response.headers["X-Accel-Buffering"] = "no" stream = Stream.new(response.stream) @agent.ask(prompt, stream:) stream.finish ensure response.stream.close end |
#create ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/controllers/rails_llm/agents_controller.rb', line 19 def create @agent = Agent.create!(create_params) respond_to do |format| format.html { redirect_to agent_path(@agent) } format.json { render json: {location: agent_path(@agent)} } end end |
#index ⇒ Object
11 12 13 |
# File 'app/controllers/rails_llm/agents_controller.rb', line 11 def index @agent = Agent.new end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/rails_llm/agents_controller.rb', line 15 def show @messages = end |