Edits history of script submission #9781 for ' List generation presets (vectara)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Vectara = {
    	apiKey: string
    }
    /**
     * List generation presets
     * 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`.
    
     */
    export async function main(
    	auth: Vectara,
    	llm_name: string | undefined,
    	limit: string | undefined,
    	page_key: string | undefined
    ) {
    	const url = new URL(`https://api.vectara.io/v2/generation_presets`)
    	for (const [k, v] of [
    		['llm_name', llm_name],
    		['limit', limit],
    		['page_key', page_key]
    	]) {
    		if (v !== undefined && v !== '' && k !== undefined) {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			'x-api-key': auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 581 days ago