gleamunison/llm_wire

Provider wire codec for the LLM ability (pure data <-> JSON).

One owner for the provider wire format: request building, response parsing, JSON string escaping, and the house completion shape. Split from llm.gleam so each module keeps exactly one concern — llm.gleam owns the ability host surface (handlers, budget gate, config), this module owns the wire.

Values

pub fn build_request(
  cfg: llm_types.ProviderConfig,
  messages: List(llm_types.Message),
) -> #(String, List(#(String, String)), String)
pub fn completion_decoder() -> decode.Decoder(
  llm_types.Completion,
)

Decoder for the house completion shape — what completion_json emits and mocks return. Provider wire bodies go through parse_response instead.

pub fn completion_json(c: llm_types.Completion) -> BitArray
pub fn messages_json(msgs: List(llm_types.Message)) -> String
pub fn parse_response(
  provider: llm_types.Provider,
  status: Int,
  body: String,
) -> Result(llm_types.Completion, llm_types.LlmError)
pub fn unwrap_bit(b: BitArray) -> String
✨ Search Document