llm_wire/limit

Names every byte and count bound that LLM Wire applies to a call.

Set a bound with llm_wire.with_limit; a call that exceeds it fails with error.LimitExceeded naming the same Limit, so the error says which setter raises it:

import llm_wire
import llm_wire/limit

let config =
  openai.new(key) |> openai.config
  |> llm_wire.with_limit(limit.TotalTextBytes, 8_388_608)
LimitDefaultBounds
RequestBytes1 MiBthe encoded request body
ChunkBytes64 KiBone transport chunk
LineBytes1 MiBone SSE line
EventBytes1 MiBone SSE event
ResponseBodyBytes8 MiBthe whole streamed response
ErrorBodyBytes64 KiBthe body of a non-200 response
QueueCount500progress items waiting for next
QueueBytes2 MiBbytes of progress waiting for next
ActiveBlocks64text, reasoning and tool blocks open at once
TextBytesPerBlock1 MiBone text, refusal or reasoning block
TotalTextBytes4 MiBall text of one response
ArgumentBytesPerCall1 MiBone tool call’s arguments
TotalArgumentBytes4 MiBall tool-call arguments of one response
ProviderMetadataBytes1 MiBids, signatures and replay data
ExtensionBytes16 KiBthe name of an unrecognized provider event

Every limit must be positive; llm_wire.prepare rejects any other value with error.InvalidSetting(error.LimitSetting(limit), ..).

Types

One bound of a call. Never gains a variant without a new setter value.

pub type Limit {
  RequestBytes
  ChunkBytes
  LineBytes
  EventBytes
  ResponseBodyBytes
  ErrorBodyBytes
  QueueCount
  QueueBytes
  ActiveBlocks
  TextBytesPerBlock
  TotalTextBytes
  ArgumentBytesPerCall
  TotalArgumentBytes
  ProviderMetadataBytes
  ExtensionBytes
}

Constructors

  • RequestBytes
  • ChunkBytes
  • LineBytes
  • EventBytes
  • ResponseBodyBytes
  • ErrorBodyBytes
  • QueueCount
  • QueueBytes
  • ActiveBlocks
  • TextBytesPerBlock
  • TotalTextBytes
  • ArgumentBytesPerCall
  • TotalArgumentBytes
  • ProviderMetadataBytes
  • ExtensionBytes

Values

pub fn all() -> List(Limit)

Every limit, in the order of the table above.

pub fn default(limit: Limit) -> Int

The default value of a limit.

pub fn name(limit: Limit) -> String

A stable snake_case name for logs and stored records, such as "total_text_bytes".

✨ Search Document