//native
type Telnyx = {
apiKey: string
}
/**
* Embed documents
* Perform embedding on a Telnyx Storage Bucket using the a embedding model.
*/
export async function main(
auth: Telnyx,
body: {
bucket_name: string
document_chunk_size?: number
document_chunk_overlap_size?: number
embedding_model?:
| 'thenlper/gte-large'
| 'intfloat/multilingual-e5-large'
| 'sentence-transformers/all-mpnet-base-v2'
loader?: 'default' | 'intercom'
}
) {
const url = new URL(`https://api.telnyx.com/v2/ai/embeddings`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago