defmodule NolaWeb.GptController do use NolaWeb, :controller require Logger plug NolaWeb.ContextPlug def result(conn, params = %{"id" => result_id}) do case Nola.Plugins.Gpt.get_result(result_id) do {:ok, result} -> network = Map.get(params, "network") channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) render(conn, "result.html", network: network, channel: channel, result: result) {:error, :not_found} -> conn |> put_status(404) |> text("Page not found") end end def prompt(conn, params = %{"id" => prompt_id}) do case Nola.Plugins.Gpt.get_prompt(prompt_id) do {:ok, prompt} -> network = Map.get(params, "network") channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) render(conn, "prompt.html", network: network, channel: channel, prompt: prompt) {:error, :not_found} -> conn |> put_status(404) |> text("Page not found") end end end