Skip to content

Commit 17a3ca0

Browse files
committed
docs: reuse the TEI parser in the house-format example, document unknown apiStyle
1 parent c818091 commit 17a3ca0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,25 @@ Config takes `baseURL` and `apiStyle`, with optional `model` (required by Cohere
4040

4141
Jina's `/rerank` follows the Cohere shape and is served by the `cohere` adapter.
4242

43-
To add a house format, build a registry with `createRerankAdapterRegistry` and pass it as `registry`:
43+
To add a house format, such as a TEI-shaped reply served at `/score`, build a registry with `createRerankAdapterRegistry` and pass it as `registry`:
4444

4545
```ts
4646
import {
4747
createRerankAdapterRegistry,
4848
rerankAdapterRegistry,
4949
} from "@corbits/reranking";
5050

51+
const tei = rerankAdapterRegistry.resolve("tei");
52+
5153
const registry = createRerankAdapterRegistry({
52-
tei: rerankAdapterRegistry.resolve("tei"),
54+
tei,
5355
house: {
5456
buildRequest: (query, docs, config) => ({
5557
url: `${config.baseURL}/score`,
5658
headers: { "content-type": "application/json" },
5759
body: JSON.stringify({ query, texts: docs.map((doc) => doc.text) }),
5860
}),
59-
parseResponse: (body) => body as Array<{ index: number; score: number }>,
61+
parseResponse: tei.parseResponse,
6062
},
6163
});
6264
```
@@ -65,7 +67,7 @@ Providers reply with positions into the request array, so each score maps back t
6567

6668
## Errors
6769

68-
Failures throw `RerankRequestError` (`extends Error`), carrying the classified `InferenceError` from `@intx/inference` as `reason` and the request `url`. That covers transport failures, HTTP errors, and replies in the wrong shape; retryable errors are retried first under the `retryPolicy` option, which defaults to `createDefaultRetryPolicy()`. An invalid config, including a missing `model` for Cohere or Voyage, throws arktype's `TraversalError` before any request is sent.
70+
Failures throw `RerankRequestError` (`extends Error`), carrying the classified `InferenceError` from `@intx/inference` as `reason` and the request `url`. That covers transport failures, HTTP errors, and replies in the wrong shape; retryable errors are retried first under the `retryPolicy` option, which defaults to `createDefaultRetryPolicy()`. An invalid config, including a missing `model` for Cohere or Voyage, throws arktype's `TraversalError` before any request is sent; an `apiStyle` the registry does not know throws a plain `Error` naming it.
6971

7072
Fallback is left to the caller: catch the error and keep your own ordering if a reranker outage should not fail search.
7173

0 commit comments

Comments
 (0)