Packages
A Fair Source multi-agent runtime with deterministic agent scoring and replayable run history.
Retired package: Deprecated - superseded — operator console moved to the Syntropy app
Current section
Files
Jump to
Current section
Files
lib/syntropy_web/controllers/api/runtime_config_controller.ex
defmodule SyntropyWeb.Api.RuntimeConfigController do
use SyntropyWeb, :controller
alias Syntropy.{RuntimeConfig, Usage}
alias SyntropyWeb.Api.ControllerHelpers
@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, _params) do
json(conn, %{data: RuntimeConfig.report()})
end
@spec update_provider(Plug.Conn.t(), map()) :: Plug.Conn.t()
def update_provider(conn, params) do
case RuntimeConfig.apply_provider(params) do
{:ok, report} ->
json(conn, %{data: report})
{:error, errors} ->
ControllerHelpers.invalid_request(
conn,
"Provider configuration is invalid.",
Enum.map(errors, &%{message: &1})
)
end
end
@spec test_provider(Plug.Conn.t(), map()) :: Plug.Conn.t()
def test_provider(conn, params) do
json(conn, %{data: RuntimeConfig.test_provider(params)})
end
@spec update_limits(Plug.Conn.t(), map()) :: Plug.Conn.t()
def update_limits(conn, params) do
case Usage.apply_budget(Map.get(params, "usage_budget_tokens")) do
{:ok, _budget} ->
json(conn, %{data: RuntimeConfig.limits_report()})
{:error, message} ->
ControllerHelpers.invalid_request(conn, message, [])
end
end
end