0

List generation presets

by
Published Nov 5, 2024

List generation presets used for query or chat requests. Generation presets are the build of properties used to configure generation for a request. This includes the template that renders the prompt, and various generation settings like `temperature`.

Script vectara Verified

The script

Submitted by hugo697 Bun
Verified 581 days ago
1
//native
2
type Vectara = {
3
	apiKey: string
4
}
5
/**
6
 * List generation presets
7
 * List generation presets used for query or chat requests. Generation presets are
8
the build of properties used to configure generation for a request. This includes
9
the template that renders the prompt, and various generation settings like
10
`temperature`.
11

12
 */
13
export async function main(
14
	auth: Vectara,
15
	llm_name: string | undefined,
16
	limit: string | undefined,
17
	page_key: string | undefined
18
) {
19
	const url = new URL(`https://api.vectara.io/v2/generation_presets`)
20
	for (const [k, v] of [
21
		['llm_name', llm_name],
22
		['limit', limit],
23
		['page_key', page_key]
24
	]) {
25
		if (v !== undefined && v !== '' && k !== undefined) {
26
			url.searchParams.append(k, v)
27
		}
28
	}
29
	const response = await fetch(url, {
30
		method: 'GET',
31
		headers: {
32
			'x-api-key': auth.apiKey
33
		},
34
		body: undefined
35
	})
36
	if (!response.ok) {
37
		const text = await response.text()
38
		throw new Error(`${response.status} ${text}`)
39
	}
40
	return await response.json()
41
}
42