Leon4gr45's picture
Upload folder using huggingface_hub (part 2)
1477a90 verified
Raw
History Blame Contribute Delete
5.93 kB
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'
import { type Result, type RequestOptions } from '../lib/types.js'
import { request } from '../lib/request.js'
import { toURLSearchParams, encodeSort } from '../lib/encodings.js'
import {
toWire,
toPathWire,
fromWire,
assertValid,
toSnakeCase,
} from '../lib/wire.js'
import * as schemas from '../models/schemas.js'
import type {
ListLlmCostPricesRequest,
ListLlmCostPricesResponse,
GetLlmCostPriceRequest,
GetLlmCostPriceResponse,
ListLlmCostOverridesRequest,
ListLlmCostOverridesResponse,
CreateLlmCostOverrideRequest,
CreateLlmCostOverrideResponse,
DeleteLlmCostOverrideRequest,
DeleteLlmCostOverrideResponse,
} from '../models/operations/llmCost.js'
/**
* List LLM cost prices
*
* List global LLM cost prices. Returns prices with overrides applied if any.
*
* GET /openmeter/llm-cost/prices
*/
export function listLlmCostPrices(
client: Client,
req: ListLlmCostPricesRequest = {},
options?: RequestOptions,
): Promise<Result<ListLlmCostPricesResponse>> {
return request(() => {
if (client._options.validate && req.sort !== undefined) {
assertValid(schemas.listLlmCostPricesQueryParams.shape.sort, req.sort)
}
const query = toWire(
{
filter: req.filter,
sort: encodeSort(req.sort, toSnakeCase),
page: req.page,
},
schemas.listLlmCostPricesQueryParams,
)
if (client._options.validate) {
assertValid(schemas.listLlmCostPricesQueryParamsWire, query)
}
const searchParams = toURLSearchParams(query)
return http(client)
.get('openmeter/llm-cost/prices', { ...options, searchParams })
.json()
.then((data) => {
if (client._options.validate) {
assertValid(schemas.listLlmCostPricesResponseWire, data)
}
return fromWire(data, schemas.listLlmCostPricesResponse)
})
})
}
/**
* Get LLM cost price
*
* Get a specific LLM cost price by ID. Returns the price with overrides applied if
* any.
*
* GET /openmeter/llm-cost/prices/{priceId}
*/
export function getLlmCostPrice(
client: Client,
req: GetLlmCostPriceRequest,
options?: RequestOptions,
): Promise<Result<GetLlmCostPriceResponse>> {
return request(() => {
const pathParamsInput = {
priceId: req.priceId,
}
const pathParams = client._options.validate
? toPathWire(pathParamsInput, schemas.getLlmCostPricePathParams)
: pathParamsInput
if (client._options.validate) {
assertValid(schemas.getLlmCostPricePathParamsWire, pathParams)
}
const path = `openmeter/llm-cost/prices/${(() => {
if (pathParams.priceId === undefined) {
throw new Error('missing path parameter: priceId')
}
return encodeURIComponent(String(pathParams.priceId))
})()}`
return http(client)
.get(path, options)
.json()
.then((data) => {
if (client._options.validate) {
assertValid(schemas.getLlmCostPriceResponseWire, data)
}
return fromWire(data, schemas.getLlmCostPriceResponse)
})
})
}
/**
* List LLM cost overrides
*
* List per-namespace price overrides.
*
* GET /openmeter/llm-cost/overrides
*/
export function listLlmCostOverrides(
client: Client,
req: ListLlmCostOverridesRequest = {},
options?: RequestOptions,
): Promise<Result<ListLlmCostOverridesResponse>> {
return request(() => {
const query = toWire(
{
filter: req.filter,
page: req.page,
},
schemas.listLlmCostOverridesQueryParams,
)
if (client._options.validate) {
assertValid(schemas.listLlmCostOverridesQueryParamsWire, query)
}
const searchParams = toURLSearchParams(query)
return http(client)
.get('openmeter/llm-cost/overrides', { ...options, searchParams })
.json()
.then((data) => {
if (client._options.validate) {
assertValid(schemas.listLlmCostOverridesResponseWire, data)
}
return fromWire(data, schemas.listLlmCostOverridesResponse)
})
})
}
/**
* Create LLM cost override
*
* Create a per-namespace price override.
*
* POST /openmeter/llm-cost/overrides
*/
export function createLlmCostOverride(
client: Client,
req: CreateLlmCostOverrideRequest,
options?: RequestOptions,
): Promise<Result<CreateLlmCostOverrideResponse>> {
return request(() => {
const body = toWire(req, schemas.createLlmCostOverrideBody)
if (client._options.validate) {
assertValid(schemas.createLlmCostOverrideBodyWire, body)
}
return http(client)
.post('openmeter/llm-cost/overrides', { ...options, json: body })
.json()
.then((data) => {
if (client._options.validate) {
assertValid(schemas.createLlmCostOverrideResponseWire, data)
}
return fromWire(data, schemas.createLlmCostOverrideResponse)
})
})
}
/**
* Delete LLM cost override
*
* Delete a per-namespace price override.
*
* DELETE /openmeter/llm-cost/overrides/{priceId}
*/
export function deleteLlmCostOverride(
client: Client,
req: DeleteLlmCostOverrideRequest,
options?: RequestOptions,
): Promise<Result<DeleteLlmCostOverrideResponse>> {
return request(async () => {
const pathParamsInput = {
priceId: req.priceId,
}
const pathParams = client._options.validate
? toPathWire(pathParamsInput, schemas.deleteLlmCostOverridePathParams)
: pathParamsInput
if (client._options.validate) {
assertValid(schemas.deleteLlmCostOverridePathParamsWire, pathParams)
}
const path = `openmeter/llm-cost/overrides/${(() => {
if (pathParams.priceId === undefined) {
throw new Error('missing path parameter: priceId')
}
return encodeURIComponent(String(pathParams.priceId))
})()}`
await http(client).delete(path, options)
})
}