Edits history of script submission #9840 for ' Retrieve metadata about a corpus (vectara)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Vectara = {
    	apiKey: string
    }
    /**
     * Retrieve metadata about a corpus
     * Get metadata about a corpus. This operation is not a method of searching a corpus. 
    Specify the `corpus_key` to identify the corpus whose metadata you want to 
    retrieve. The `corpus_key` is created when the corpus is set up, either through
    the Vectara Console UI or the Create Corpus API. For more information, 
    see [Corpus Key Definition](https://docs.vectara.com/docs/api-reference/search-apis/search#corpus-key-definition).
    
     */
    export async function main(auth: Vectara, corpus_key: string) {
    	const url = new URL(`https://api.vectara.io/v2/corpora/${corpus_key}`)
    
    	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