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

main
ts 43 lines 1.37 KB
Raw
1 import type * as kendra from "@distilled.cloud/aws/kendra";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Index } from "./SearchIndex.ts";
5
6 /**
7 * `Retrieve` request with `IndexId` injected from the bound index.
8 */
9 export interface RetrieveRequest extends Omit<kendra.RetrieveRequest, "IndexId"> {}
10
11 /**
12 * Runtime binding for the `Retrieve` operation (IAM action
13 * `kendra:Retrieve`), scoped to one {@link Index}.
14 *
15 * Retrieves up to 100 semantically-relevant passages (200-token excerpts)
16 * from the index — the building block for retrieval-augmented generation
17 * (RAG) over documents synced into Kendra.
18 * Provide the implementation with
19 * `Effect.provide(AWS.Kendra.RetrieveHttp)`.
20 *
21 * ### Querying an Index
22 * **Example:** Retrieve Passages for RAG
23 * ```typescript
24 * const retrieve = yield* AWS.Kendra.Retrieve(index);
25 *
26 * const passages = yield* retrieve({ QueryText: "vacation policy" });
27 * const context = (passages.ResultItems ?? [])
28 * .map((item) => item.Content)
29 * .join("\n");
30 * ```
31 *
32 * @binding
33 */
34 export interface Retrieve extends Binding.Service<
35 Retrieve,
36 "AWS.Kendra.Retrieve",
37 (
38 index: Index,
39 ) => Effect.Effect<
40 (request: RetrieveRequest) => Effect.Effect<kendra.RetrieveResult, kendra.RetrieveError>
41 >
42 > {}
43 export const Retrieve = Binding.Service<Retrieve>("AWS.Kendra.Retrieve");