//native
type Deepinfra = {
token: string;
};
/**
* Logs Query
* Query inference logs.
* Without timestamps (from/to) returns last `limit` messages (in last month).
* With `from` only, returns first `limit` messages after `from` (inclusive).
* With `to` only, returns last `limit` messages before `to` (inclusive).
* With both `from` and `to`, return the first `limit` messages after `from`, but not later than `to`.
* `from` and `to` should be no more than a month apart.
*/
export async function main(
auth: Deepinfra,
deploy_id: string | undefined,
from: string | undefined,
to: string | undefined,
limit: string | undefined,
) {
const url = new URL(`https://api.deepinfra.com/v1/logs/query`);
for (const [k, v] of [
["deploy_id", deploy_id],
["from", from],
["to", to],
["limit", limit],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago