POST
/
v4
/
chunks
/
rank
import SGPClient from 'sgp';

const client = new SGPClient({
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const rankedChunksResponse = await client.chunks.rank({
    query: 'query',
    rank_strategy: { method: 'cross_encoder' },
    relevant_chunks: [{ chunk_id: 'chunk_id', score: 0, text: 'text' }],
  });

  console.log(rankedChunksResponse.relevant_chunks);
}

main();
{
  "relevant_chunks": [
    {
      "chunk_id": "<string>",
      "text": "<string>",
      "embedding": [
        123
      ],
      "metadata": {},
      "user_supplied_metadata": {},
      "attachment_url": "<string>",
      "title": "<string>",
      "score": 123
    }
  ]
}

Authorizations

x-api-key
string
header
required

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.