Search for documents
POST/ai/embeddings/similarity-search
Perform a similarity search on a Telnyx Storage Bucket, returning the most similar num_docs
document chunks to the query.
Currently the only available distance metric is cosine similarity which will return a distance
between 0 and 1.
The lower the distance, the more similar the returned document chunks are to the query.
A certainty
will also be returned, which is a value between 0 and 1 where the higher the certainty, the more similar the document.
You can read more about Weaviate distance metrics here: Weaviate Docs
If a bucket was embedded using a custom loader, such as intercom
, the additional metadata will be returned in the
loader_metadata
field.
Request
- application/json
Body
required
Default value: 3
Responses
200: Successful Response
- application/json
422: Validation Error
- application/json
Request samples
curl -L 'https://api.telnyx.com/v2/ai/embeddings/similarity-search' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
-d '{
"bucket_name": "string",
"query": "string",
"num_of_docs": 3
}'
Response samples
{
"data": [
{
"document_chunk": "string",
"distance": 0,
"metadata": {
"source": "string",
"checksum": "string",
"embedding": "string",
"filename": "string",
"certainty": 0,
"loader_metadata": {}
}
}
]
}
{
"detail": [
{
"loc": [
"string",
0
],
"msg": "string",
"type": "string"
}
]
}