@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 59 lines 2 KB
Raw
1 import type * as bedrock from "@distilled.cloud/aws/bedrock-agent-runtime";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4
5 /**
6 * The `Rerank` request. The reranker model is referenced inside
7 * `rerankingConfiguration.bedrockRerankingConfiguration.modelConfiguration.modelArn`
8 * — pass the full foundation-model ARN of one of the bound models there.
9 */
10 export interface RerankRequest extends bedrock.RerankRequest {}
11
12 /**
13 * Runtime binding for `bedrock-agent-runtime:Rerank` — re-order a list of
14 * candidate documents by semantic relevance to a query using a Bedrock
15 * reranker model (e.g. `amazon.rerank-v1:0`, `cohere.rerank-v3-5:0`).
16 *
17 * Bind one or more reranker model references inside a function runtime. The
18 * binding grants the function `bedrock:Rerank` (which AWS authorizes only
19 * against `*`) plus `bedrock:InvokeModel` scoped to exactly the bound
20 * models.
21 *
22 * ### Reranking Documents
23 * **Example:** Rerank Inline Text Documents
24 * ```typescript
25 * // init
26 * const rerank = yield* Bedrock.Rerank("amazon.rerank-v1:0");
27 *
28 * // runtime
29 * const result = yield* rerank({
30 * queries: [{ type: "TEXT", textQuery: { text: "What is Alchemy?" } }],
31 * sources: docs.map((text) => ({
32 * type: "INLINE",
33 * inlineDocumentSource: { type: "TEXT", textDocument: { text } },
34 * })),
35 * rerankingConfiguration: {
36 * type: "BEDROCK_RERANKING_MODEL",
37 * bedrockRerankingConfiguration: {
38 * modelConfiguration: {
39 * modelArn: `arn:aws:bedrock:us-west-2::foundation-model/amazon.rerank-v1:0`,
40 * },
41 * },
42 * },
43 * });
44 * const best = result.results[0]; // { index, relevanceScore }
45 * ```
46 *
47 * @binding
48 */
49 export interface Rerank extends Binding.Service<
50 Rerank,
51 "AWS.Bedrock.Rerank",
52 (
53 model: string,
54 ...additionalModels: string[]
55 ) => Effect.Effect<
56 (request: RerankRequest) => Effect.Effect<bedrock.RerankResponse, bedrock.RerankError>
57 >
58 > {}
59 export const Rerank = Binding.Service<Rerank>("AWS.Bedrock.Rerank");