0

List LLMs

by
Published Nov 5, 2024

List LLMs that can be used with query and chat endpoints. The LLM is not directly specified in a query, but instead a `generation_preset_name` is used. The `generation_preset_name` property in generation parameters can be found as the `name` property on the Generations Presets retrieved from `/v2/generation_presets`.

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 LLMs
7
 * List LLMs that can be used with query and chat endpoints. The LLM is not directly specified in a query,
8
but instead a `generation_preset_name` is used. The `generation_preset_name` property in generation parameters
9
can be found as the `name` property on the Generations Presets retrieved from `/v2/generation_presets`.
10

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