Wardrik.Setup (wardrik v0.1.0-rc.1)

Copy Markdown

Builds %Wardrik{} from Wardrik.start_link/1's options, and each agent's options.

Summary

Functions

Returns the options WardrikCore.start_agent/2 takes for the agent opts describe.

Returns an agent's :policy as a list of policies. nil is [].

Builds a policy from its rules. Returns a WardrikPolicy or nil as given.

Returns the price of the model spec, in US dollars per million tokens.

Builds a %Wardrik{} from Wardrik.start_link/1's options.

Functions

agent(wardrik, opts)

@spec agent(Wardrik.t(), keyword()) :: keyword()

Returns the options WardrikCore.start_agent/2 takes for the agent opts describe.

Adds Wardrik's events, prices, credentials and keys, spending, middleware and policies. The agent's own :policy is held alongside Wardrik's.

policies(policy)

@spec policies(WardrikPolicy.t() | [WardrikPolicy.t()] | keyword() | map() | nil) :: [
  WardrikPolicy.t()
]

Returns an agent's :policy as a list of policies. nil is [].

policy(policy)

@spec policy(WardrikPolicy.t() | keyword() | map() | nil) :: WardrikPolicy.t() | nil

Builds a policy from its rules. Returns a WardrikPolicy or nil as given.

price(spec, price)

@spec price(String.t(), keyword()) :: WardrikCore.Usage.price()

Returns the price of the model spec, in US dollars per million tokens.

# Its own rates
Wardrik.Setup.price("acme:model-1", input: 0.5, output: 1.5)

# Another model's catalog price, 10% more
Wardrik.Setup.price("zai_coding_plan:glm-5.1", priced_as: "zai:glm-5.1", markup: 0.1)

Options

  • :input and :output - rates. Both required unless :priced_as is set.
  • :cache_read and :cache_write - optional rates.
  • :priced_as - a model whose catalog price to use. Can't be combined with rates.
  • :markup - added on top, as 0.1 for 10%. 0 unless set.

Raises ArgumentError if the price is invalid.

wardrik(opts)

@spec wardrik(keyword()) :: Wardrik.t()

Builds a %Wardrik{} from Wardrik.start_link/1's options.