//native
type Vectara = {
apiKey: string
}
/**
* Create a corpus
* Create a corpus, which is a container to store documents and associated metadata. This is where you
create the unique `corpus_key` that identifies the corpus. The `corpus_key` can be custom-defined
following your preferred naming convention, allowing you to easily manage the corpus's data and
reference it in queries. 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,
body: {
key: string
name?: string
description?: string
queries_are_answers?: false | true
documents_are_questions?: false | true
encoder_id?: string
encoder_name?: string
filter_attributes?: {
name: string
level: 'document' | 'part'
description?: string
indexed?: false | true
type:
| 'boolean'
| 'integer'
| 'real_number'
| 'text'
| 'list[integer]'
| 'list[real_number]'
| 'list[text]'
}[]
custom_dimensions?: {
name: string
description?: string
indexing_default?: number
querying_default?: number
}[]
}
) {
const url = new URL(`https://api.vectara.io/v2/corpora`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 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 581 days ago