1 | |
2 | type Ultravox = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Tools update |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Ultravox, |
11 | tool_id: string, |
12 | body: { |
13 | toolId: string; |
14 | name: string; |
15 | created: string; |
16 | definition: { |
17 | modelToolName?: string; |
18 | description?: string; |
19 | dynamicParameters?: { |
20 | name?: string; |
21 | location?: |
22 | | "PARAMETER_LOCATION_UNSPECIFIED" |
23 | | "PARAMETER_LOCATION_QUERY" |
24 | | "PARAMETER_LOCATION_PATH" |
25 | | "PARAMETER_LOCATION_HEADER" |
26 | | "PARAMETER_LOCATION_BODY"; |
27 | schema?: {}; |
28 | required?: false | true; |
29 | }[]; |
30 | staticParameters?: { |
31 | name?: string; |
32 | location?: |
33 | | "PARAMETER_LOCATION_UNSPECIFIED" |
34 | | "PARAMETER_LOCATION_QUERY" |
35 | | "PARAMETER_LOCATION_PATH" |
36 | | "PARAMETER_LOCATION_HEADER" |
37 | | "PARAMETER_LOCATION_BODY"; |
38 | value?: {}; |
39 | }[]; |
40 | automaticParameters?: { |
41 | name?: string; |
42 | location?: |
43 | | "PARAMETER_LOCATION_UNSPECIFIED" |
44 | | "PARAMETER_LOCATION_QUERY" |
45 | | "PARAMETER_LOCATION_PATH" |
46 | | "PARAMETER_LOCATION_HEADER" |
47 | | "PARAMETER_LOCATION_BODY"; |
48 | knownValue?: |
49 | | "KNOWN_PARAM_UNSPECIFIED" |
50 | | "KNOWN_PARAM_CALL_ID" |
51 | | "KNOWN_PARAM_CONVERSATION_HISTORY" |
52 | | "KNOWN_PARAM_OUTPUT_SAMPLE_RATE"; |
53 | }[]; |
54 | requirements?: { |
55 | httpSecurityOptions?: { options?: { requirements?: {} }[] }; |
56 | requiredParameterOverrides?: string[]; |
57 | }; |
58 | timeout?: string; |
59 | precomputable?: false | true; |
60 | http?: { baseUrlPattern?: string; httpMethod?: string }; |
61 | client?: {}; |
62 | }; |
63 | }, |
64 | ) { |
65 | const url = new URL(`https://api.ultravox.ai/api/tools/${tool_id}`); |
66 |
|
67 | const response = await fetch(url, { |
68 | method: "PUT", |
69 | headers: { |
70 | "Content-Type": "application/json", |
71 | "X-API-Key": auth.apiKey, |
72 | }, |
73 | body: JSON.stringify(body), |
74 | }); |
75 | if (!response.ok) { |
76 | const text = await response.text(); |
77 | throw new Error(`${response.status} ${text}`); |
78 | } |
79 | return await response.json(); |
80 | } |
81 |
|