//native
type Ultravox = {
apiKey: string;
};
/**
* Tools update
*
*/
export async function main(
auth: Ultravox,
tool_id: string,
body: {
toolId: string;
name: string;
created: string;
definition: {
modelToolName?: string;
description?: string;
dynamicParameters?: {
name?: string;
location?:
| "PARAMETER_LOCATION_UNSPECIFIED"
| "PARAMETER_LOCATION_QUERY"
| "PARAMETER_LOCATION_PATH"
| "PARAMETER_LOCATION_HEADER"
| "PARAMETER_LOCATION_BODY";
schema?: {};
required?: false | true;
}[];
staticParameters?: {
name?: string;
location?:
| "PARAMETER_LOCATION_UNSPECIFIED"
| "PARAMETER_LOCATION_QUERY"
| "PARAMETER_LOCATION_PATH"
| "PARAMETER_LOCATION_HEADER"
| "PARAMETER_LOCATION_BODY";
value?: {};
}[];
automaticParameters?: {
name?: string;
location?:
| "PARAMETER_LOCATION_UNSPECIFIED"
| "PARAMETER_LOCATION_QUERY"
| "PARAMETER_LOCATION_PATH"
| "PARAMETER_LOCATION_HEADER"
| "PARAMETER_LOCATION_BODY";
knownValue?:
| "KNOWN_PARAM_UNSPECIFIED"
| "KNOWN_PARAM_CALL_ID"
| "KNOWN_PARAM_CONVERSATION_HISTORY"
| "KNOWN_PARAM_OUTPUT_SAMPLE_RATE";
}[];
requirements?: {
httpSecurityOptions?: { options?: { requirements?: {} }[] };
requiredParameterOverrides?: string[];
};
timeout?: string;
precomputable?: false | true;
http?: { baseUrlPattern?: string; httpMethod?: string };
client?: {};
};
},
) {
const url = new URL(`https://api.ultravox.ai/api/tools/${tool_id}`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
"X-API-Key": auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago