Packages

Gleam SDK for Dagger — type-safe pipelines via GraphQL codegen

Current section

Files

Jump to
dagger_gleam src dagger dsl l_l_m_token_usage.gleam
Raw

src/dagger/dsl/l_l_m_token_usage.gleam

// AUTO-GENERATED BY DAGGER_GLEAM - DO NOT EDIT
import dagger/types.{type Client, type Try} as types
import dagger/interpreter
import dagger/dsl/types as t
import gleam/dynamic/decode
import gleam/list
pub fn l_l_m_token_usage(id id: t.LLMTokenUsage) -> t.LLMTokenUsage {
let field = types.Field(name: "loadLLMTokenUsageFromID", args: [#("id", types.GDeferred(id.op))], subfields: [])
t.LLMTokenUsage(op: types.Pure([field]))
}
pub fn cached_token_reads(parent: t.LLMTokenUsage, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "cachedTokenReads", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("cachedTokenReads")))
}
}
)
}
handler(interpreter.run(op, client))
}
pub fn cached_token_writes(parent: t.LLMTokenUsage, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "cachedTokenWrites", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("cachedTokenWrites")))
}
}
)
}
handler(interpreter.run(op, client))
}
/// A unique identifier for this LLMTokenUsage.
pub fn id(parent: t.LLMTokenUsage) -> t.LLMTokenUsage {
let field = types.Field(name: "id", args: [], subfields: [])
let new_op = {
use q <- types.bind(parent.op)
types.Pure(list.append(q, [field]))
}
t.LLMTokenUsage(op: new_op)
}
pub fn input_tokens(parent: t.LLMTokenUsage, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "inputTokens", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("inputTokens")))
}
}
)
}
handler(interpreter.run(op, client))
}
pub fn output_tokens(parent: t.LLMTokenUsage, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "outputTokens", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("outputTokens")))
}
}
)
}
handler(interpreter.run(op, client))
}
pub fn total_tokens(parent: t.LLMTokenUsage, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "totalTokens", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("totalTokens")))
}
}
)
}
handler(interpreter.run(op, client))
}