Edits history of script submission #9764 for ' Delete a turn (vectara)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Vectara = {
    	apiKey: string
    }
    /**
     * Delete a turn
     * Delete a turn from a chat. This will delete all subsequent turns in the chat.
     */
    export async function main(auth: Vectara, chat_id: string, turn_id: string) {
    	const url = new URL(`https://api.vectara.io/v2/chats/${chat_id}/turns/${turn_id}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		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.text()
    }
    

    Submitted by hugo697 581 days ago