//native
type Box = {
token: string;
};
/**
* Get AI agent default configuration
* Get the AI agent default config
*/
export async function main(
auth: Box,
mode: "ask" | "text_gen" | "extract" | "extract_structured" | undefined,
language: string | undefined,
model: string | undefined,
) {
const url = new URL(`https://api.box.com/2.0/ai_agent_default`);
for (const [k, v] of [
["mode", mode],
["language", language],
["model", model],
]) {
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