import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
// Automatically fetches more pages as needed.
for await (const chunk of client.knowledgeBases.chunks.list('knowledge_base_id')) {
console.log(chunk.chunk_id);
}
{
"chunks": [
{
"chunk_id": "<string>",
"text": "<string>",
"embedding": [
123
],
"metadata": {},
"user_supplied_metadata": {},
"attachment_url": "<string>",
"title": "<string>"
}
]
}
Get chunks from a knowledge base using chunk IDs or a matching metadata field. This API will query from the Vector Database using the passed in filters and optionally can return the embeddings.
This API can be used to get a list of chunks from a knowledge base. Given a chunk id, a metadata field and value, or both, matching chunks are searched for in the knowledge base given by knowledge base id.
import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
// Automatically fetches more pages as needed.
for await (const chunk of client.knowledgeBases.chunks.list('knowledge_base_id')) {
console.log(chunk.chunk_id);
}
{
"chunks": [
{
"chunk_id": "<string>",
"text": "<string>",
"embedding": [
123
],
"metadata": {},
"user_supplied_metadata": {},
"attachment_url": "<string>",
"title": "<string>"
}
]
}
Optional search by chunk_id
Optional search by metadata fields, encoded as a JSON object
Maximum number of chunks returned by the get_chunks endpoint. Defaults to 10 and cannot be greater than 2000.
1 <= x <= 2000
Successful Response
The response is of type object
.