@effect/ai-cloudflare 0.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +410 -0
- package/CLAUDE.md +410 -0
- package/LICENSE +21 -0
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +52 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +7 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +163 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/40_sql/10_basics.ts +175 -0
- package/ai-docs/src/40_sql/index.md +6 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +118 -0
- package/ai-docs/src/51_http-server/20_testing.ts +100 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +162 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +24 -0
- package/dist/CloudflareClient.d.ts +79 -0
- package/dist/CloudflareClient.d.ts.map +1 -0
- package/dist/CloudflareClient.js +86 -0
- package/dist/CloudflareClient.js.map +1 -0
- package/dist/CloudflareDecisionModel.d.ts +49 -0
- package/dist/CloudflareDecisionModel.d.ts.map +1 -0
- package/dist/CloudflareDecisionModel.js +122 -0
- package/dist/CloudflareDecisionModel.js.map +1 -0
- package/dist/CloudflareSchema.d.ts +186 -0
- package/dist/CloudflareSchema.d.ts.map +1 -0
- package/dist/CloudflareSchema.js +128 -0
- package/dist/CloudflareSchema.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/errors.d.ts +7 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +109 -0
- package/dist/internal/errors.js.map +1 -0
- package/package.json +47 -9
- package/src/CloudflareClient.ts +149 -0
- package/src/CloudflareDecisionModel.ts +111 -0
- package/src/CloudflareSchema.ts +131 -0
- package/src/index.ts +23 -0
- package/src/internal/errors.ts +101 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "../tsconfig.base.json",
|
|
4
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"rootDir": ".",
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"declaration": false,
|
|
9
|
+
"declarationMap": false,
|
|
10
|
+
"composite": false,
|
|
11
|
+
"incremental": false,
|
|
12
|
+
"types": ["node"],
|
|
13
|
+
"plugins": [
|
|
14
|
+
{
|
|
15
|
+
"name": "@effect/language-service",
|
|
16
|
+
"namespaceImportPackages": [],
|
|
17
|
+
"diagnosticSeverity": {
|
|
18
|
+
"floatingEffect": "off",
|
|
19
|
+
"preferSchemaOverJson": "off"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for Cloudflare Clef decisions through Workers AI REST.
|
|
3
|
+
*
|
|
4
|
+
* @stability unstable
|
|
5
|
+
* @since 4.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as AiError from "effect/ai/AiError";
|
|
8
|
+
import * as Config from "effect/Config";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
12
|
+
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as Redacted from "effect/Redacted";
|
|
14
|
+
import * as CloudflareSchema from "./CloudflareSchema.ts";
|
|
15
|
+
/**
|
|
16
|
+
* Low-level Cloudflare decision operations.
|
|
17
|
+
*
|
|
18
|
+
* @stability unstable
|
|
19
|
+
* @category services
|
|
20
|
+
* @since 4.0.0
|
|
21
|
+
*/
|
|
22
|
+
export interface Service {
|
|
23
|
+
readonly client: HttpClient.HttpClient;
|
|
24
|
+
readonly createDecisions: (request: typeof CloudflareSchema.DecisionsRequest.Encoded) => Effect.Effect<typeof CloudflareSchema.DecisionsResponse.Type, AiError.AiError>;
|
|
25
|
+
}
|
|
26
|
+
declare const CloudflareClient_base: Context.ServiceClass<CloudflareClient, "@effect/ai-cloudflare/CloudflareClient", Service>;
|
|
27
|
+
/**
|
|
28
|
+
* Cloudflare Workers AI client service.
|
|
29
|
+
*
|
|
30
|
+
* @stability unstable
|
|
31
|
+
* @category services
|
|
32
|
+
* @since 4.0.0
|
|
33
|
+
*/
|
|
34
|
+
export declare class CloudflareClient extends CloudflareClient_base {
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Account, authentication, API base URL, and HTTP customization options.
|
|
38
|
+
*
|
|
39
|
+
* @stability unstable
|
|
40
|
+
* @category options
|
|
41
|
+
* @since 4.0.0
|
|
42
|
+
*/
|
|
43
|
+
export interface Options {
|
|
44
|
+
readonly accountId: string;
|
|
45
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
46
|
+
readonly apiUrl?: string | undefined;
|
|
47
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Builds a Cloudflare client without automatic retries.
|
|
51
|
+
*
|
|
52
|
+
* @stability unstable
|
|
53
|
+
* @category constructors
|
|
54
|
+
* @since 4.0.0
|
|
55
|
+
*/
|
|
56
|
+
export declare const make: (options: Options) => Effect.Effect<Service, never, HttpClient.HttpClient>;
|
|
57
|
+
/**
|
|
58
|
+
* Provides a Cloudflare client from explicit options.
|
|
59
|
+
*
|
|
60
|
+
* @stability unstable
|
|
61
|
+
* @category layers
|
|
62
|
+
* @since 4.0.0
|
|
63
|
+
*/
|
|
64
|
+
export declare const layer: (options: Options) => Layer.Layer<CloudflareClient, never, HttpClient.HttpClient>;
|
|
65
|
+
/**
|
|
66
|
+
* Provides a client from configuration, defaulting to CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN.
|
|
67
|
+
*
|
|
68
|
+
* @stability unstable
|
|
69
|
+
* @category layers
|
|
70
|
+
* @since 4.0.0
|
|
71
|
+
*/
|
|
72
|
+
export declare const layerConfig: (options?: {
|
|
73
|
+
readonly accountId?: Config.Config<string> | undefined;
|
|
74
|
+
readonly apiKey?: Config.Config<Redacted.Redacted<string>> | undefined;
|
|
75
|
+
readonly apiUrl?: Config.Config<string> | undefined;
|
|
76
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
|
|
77
|
+
}) => Layer.Layer<CloudflareClient, Config.ConfigError, HttpClient.HttpClient>;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=CloudflareClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareClient.d.ts","sourceRoot":"","sources":["../src/CloudflareClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAGpD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAGzD;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAA;IACtC,QAAQ,CAAC,eAAe,EAAE,CACxB,OAAO,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,OAAO,KACtD,MAAM,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO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
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for Cloudflare Clef decisions through Workers AI REST.
|
|
3
|
+
*
|
|
4
|
+
* @stability unstable
|
|
5
|
+
* @since 4.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as AiError from "effect/ai/AiError";
|
|
8
|
+
import * as Config from "effect/Config";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import { flow, identity } from "effect/Function";
|
|
12
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
13
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
14
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
15
|
+
import * as Layer from "effect/Layer";
|
|
16
|
+
import * as Redacted from "effect/Redacted";
|
|
17
|
+
import * as Schema from "effect/Schema";
|
|
18
|
+
import * as CloudflareSchema from "./CloudflareSchema.js";
|
|
19
|
+
import * as Errors from "./internal/errors.js";
|
|
20
|
+
/**
|
|
21
|
+
* Cloudflare Workers AI client service.
|
|
22
|
+
*
|
|
23
|
+
* @stability unstable
|
|
24
|
+
* @category services
|
|
25
|
+
* @since 4.0.0
|
|
26
|
+
*/
|
|
27
|
+
export class CloudflareClient extends /*#__PURE__*/Context.Service()("@effect/ai-cloudflare/CloudflareClient") {}
|
|
28
|
+
const decodeResponse = /*#__PURE__*/HttpClientResponse.schemaBodyJson(/*#__PURE__*/Schema.Union([/*#__PURE__*/Schema.Struct({
|
|
29
|
+
success: /*#__PURE__*/Schema.Literal(true),
|
|
30
|
+
result: CloudflareSchema.DecisionsResponse
|
|
31
|
+
}), /*#__PURE__*/Schema.Struct({
|
|
32
|
+
success: /*#__PURE__*/Schema.Literal(false)
|
|
33
|
+
})]));
|
|
34
|
+
/**
|
|
35
|
+
* Builds a Cloudflare client without automatic retries.
|
|
36
|
+
*
|
|
37
|
+
* @stability unstable
|
|
38
|
+
* @category constructors
|
|
39
|
+
* @since 4.0.0
|
|
40
|
+
*/
|
|
41
|
+
export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
|
|
42
|
+
const base = yield* HttpClient.HttpClient;
|
|
43
|
+
const client = base.pipe(HttpClient.mapRequest(flow(HttpClientRequest.prependUrl(options.apiUrl ?? "https://api.cloudflare.com/client/v4"), HttpClientRequest.bearerToken(Redacted.value(options.apiKey)), HttpClientRequest.acceptJson)), HttpClient.filterStatusOk, options.transformClient ?? identity);
|
|
44
|
+
const path = `/accounts/${encodeURIComponent(options.accountId)}/ai/run/@cf/cloudflare/`;
|
|
45
|
+
return CloudflareClient.of({
|
|
46
|
+
client,
|
|
47
|
+
createDecisions: payload => HttpClientRequest.bodyJson(HttpClientRequest.post(path + payload.model), payload).pipe(Effect.mapError(error => AiError.make({
|
|
48
|
+
module: "CloudflareClient",
|
|
49
|
+
method: "createDecisions",
|
|
50
|
+
reason: new AiError.InvalidRequestError({
|
|
51
|
+
description: String(error)
|
|
52
|
+
})
|
|
53
|
+
})), Effect.flatMap(client.execute), Effect.flatMap(response => decodeResponse(response).pipe(Effect.flatMap(body => body.success ? Effect.succeed(body.result) : Errors.mapResponseError(response)))), Effect.catchTags({
|
|
54
|
+
HttpClientError: Errors.mapHttpClientError,
|
|
55
|
+
SchemaError: error => Effect.fail(AiError.make({
|
|
56
|
+
module: "CloudflareClient",
|
|
57
|
+
method: "createDecisions",
|
|
58
|
+
reason: AiError.InvalidOutputError.fromSchemaError(error)
|
|
59
|
+
}))
|
|
60
|
+
}))
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Provides a Cloudflare client from explicit options.
|
|
65
|
+
*
|
|
66
|
+
* @stability unstable
|
|
67
|
+
* @category layers
|
|
68
|
+
* @since 4.0.0
|
|
69
|
+
*/
|
|
70
|
+
export const layer = options => Layer.effect(CloudflareClient, make(options));
|
|
71
|
+
/**
|
|
72
|
+
* Provides a client from configuration, defaulting to CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN.
|
|
73
|
+
*
|
|
74
|
+
* @stability unstable
|
|
75
|
+
* @category layers
|
|
76
|
+
* @since 4.0.0
|
|
77
|
+
*/
|
|
78
|
+
export const layerConfig = options => Layer.effect(CloudflareClient, Effect.gen(function* () {
|
|
79
|
+
return yield* make({
|
|
80
|
+
accountId: yield* options?.accountId ?? Config.String("CLOUDFLARE_ACCOUNT_ID"),
|
|
81
|
+
apiKey: yield* options?.apiKey ?? Config.Redacted("CLOUDFLARE_API_TOKEN"),
|
|
82
|
+
apiUrl: options?.apiUrl ? yield* options.apiUrl : undefined,
|
|
83
|
+
transformClient: options?.transformClient
|
|
84
|
+
});
|
|
85
|
+
}));
|
|
86
|
+
//# sourceMappingURL=CloudflareClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareClient.js","names":[],"sources":["../src/CloudflareClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;AAMA,OAAO,KAAK,OAAO,MAAM,mBAAmB;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,IAAI,EAAE,QAAQ,QAAQ,iBAAiB;AAChD,OAAO,KAAK,UAAU,MAAM,wBAAwB;AACpD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B;AAClE,OAAO,KAAK,kBAAkB,MAAM,gCAAgC;AACpE,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,gBAAgB,MAAM,uBAAuB;AACzD,OAAO,KAAK,MAAM,MAAM,sBAAsB;AAgB9C;;;;;;;AAOA,OAAM,MAAO,gBACX,sBAAQ,OAAO,CAAC,OAAO,EAA6B,CAAC,wCAAwC,CAAC;AAiBhG,MAAM,cAAc,gBAAG,kBAAk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AO,EAAE;GAC3B,CAAC;AACJ,CAAC,CAAC,CACH","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Clef implementation of DecisionModel over Workers AI REST.
|
|
3
|
+
*
|
|
4
|
+
* @stability unstable
|
|
5
|
+
* @since 4.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as DecisionModel from "effect/ai/DecisionModel";
|
|
8
|
+
import * as AiModel from "effect/ai/Model";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import { CloudflareClient } from "./CloudflareClient.ts";
|
|
12
|
+
import type * as CloudflareSchema from "./CloudflareSchema.ts";
|
|
13
|
+
/**
|
|
14
|
+
* Cloudflare Clef model identifiers.
|
|
15
|
+
*
|
|
16
|
+
* @stability unstable
|
|
17
|
+
* @category models
|
|
18
|
+
* @since 4.0.0
|
|
19
|
+
*/
|
|
20
|
+
export type Model = typeof CloudflareSchema.DecisionsRequest.Encoded["model"];
|
|
21
|
+
/**
|
|
22
|
+
* Creates a decision model with Cloudflare provider metadata.
|
|
23
|
+
*
|
|
24
|
+
* @stability unstable
|
|
25
|
+
* @category constructors
|
|
26
|
+
* @since 4.0.0
|
|
27
|
+
*/
|
|
28
|
+
export declare const model: (model: Model) => AiModel.Model<"cloudflare", DecisionModel.DecisionModel, CloudflareClient>;
|
|
29
|
+
/**
|
|
30
|
+
* Builds a decision service with tolerance for four-decimal probability rounding.
|
|
31
|
+
*
|
|
32
|
+
* @stability unstable
|
|
33
|
+
* @category constructors
|
|
34
|
+
* @since 4.0.0
|
|
35
|
+
*/
|
|
36
|
+
export declare const make: (options: {
|
|
37
|
+
readonly model: Model;
|
|
38
|
+
}) => Effect.Effect<DecisionModel.DecisionModel, never, CloudflareClient>;
|
|
39
|
+
/**
|
|
40
|
+
* Provides DecisionModel using an existing CloudflareClient.
|
|
41
|
+
*
|
|
42
|
+
* @stability unstable
|
|
43
|
+
* @category layers
|
|
44
|
+
* @since 4.0.0
|
|
45
|
+
*/
|
|
46
|
+
export declare const layer: (options: {
|
|
47
|
+
readonly model: Model;
|
|
48
|
+
}) => Layer.Layer<DecisionModel.DecisionModel, never, CloudflareClient>;
|
|
49
|
+
//# sourceMappingURL=CloudflareDecisionModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareDecisionModel.d.ts","sourceRoot":"","sources":["../src/CloudflareDecisionModel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAE9D;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;AAE7E;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,UACT,KAAK,KACX,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,aAAa,CAAC,aAAa,EAAE,gBAAgB,CACvB,CAAA;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;oBAEc,KAAK;yEAuDnC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YACP;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,KACjC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,gBAAgB,CACT,CAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Clef implementation of DecisionModel over Workers AI REST.
|
|
3
|
+
*
|
|
4
|
+
* @stability unstable
|
|
5
|
+
* @since 4.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as DecisionModel from "effect/ai/DecisionModel";
|
|
8
|
+
import * as AiModel from "effect/ai/Model";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import { CloudflareClient } from "./CloudflareClient.js";
|
|
12
|
+
/**
|
|
13
|
+
* Creates a decision model with Cloudflare provider metadata.
|
|
14
|
+
*
|
|
15
|
+
* @stability unstable
|
|
16
|
+
* @category constructors
|
|
17
|
+
* @since 4.0.0
|
|
18
|
+
*/
|
|
19
|
+
export const model = model => AiModel.make("cloudflare", model, layer({
|
|
20
|
+
model
|
|
21
|
+
}));
|
|
22
|
+
/**
|
|
23
|
+
* Builds a decision service with tolerance for four-decimal probability rounding.
|
|
24
|
+
*
|
|
25
|
+
* @stability unstable
|
|
26
|
+
* @category constructors
|
|
27
|
+
* @since 4.0.0
|
|
28
|
+
*/
|
|
29
|
+
export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
|
|
30
|
+
const client = yield* CloudflareClient;
|
|
31
|
+
return yield* DecisionModel.make({
|
|
32
|
+
probabilityPrecision: 4,
|
|
33
|
+
decide: Effect.fnUntraced(function* ({
|
|
34
|
+
state,
|
|
35
|
+
decisions
|
|
36
|
+
}) {
|
|
37
|
+
const questions = Object.create(null);
|
|
38
|
+
for (const [key, decision] of Object.entries(decisions)) {
|
|
39
|
+
switch (decision._tag) {
|
|
40
|
+
case "Classify":
|
|
41
|
+
questions[key] = {
|
|
42
|
+
type: "choice",
|
|
43
|
+
instructions: decision.instructions,
|
|
44
|
+
criteria: decision.criteria
|
|
45
|
+
};
|
|
46
|
+
break;
|
|
47
|
+
case "Rate":
|
|
48
|
+
questions[key] = {
|
|
49
|
+
type: "score",
|
|
50
|
+
instructions: decision.instructions,
|
|
51
|
+
criteria: decision.criteria
|
|
52
|
+
};
|
|
53
|
+
break;
|
|
54
|
+
case "Probability":
|
|
55
|
+
questions[key] = {
|
|
56
|
+
type: "noul",
|
|
57
|
+
instructions: decision.instructions,
|
|
58
|
+
criteria: decision.criteria
|
|
59
|
+
};
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const response = yield* client.createDecisions({
|
|
64
|
+
model: options.model,
|
|
65
|
+
state,
|
|
66
|
+
questions
|
|
67
|
+
});
|
|
68
|
+
const answers = Object.create(null);
|
|
69
|
+
for (const [key, decision] of Object.entries(decisions)) {
|
|
70
|
+
const answer = response.answers[key];
|
|
71
|
+
switch (answer?.type) {
|
|
72
|
+
case "choice":
|
|
73
|
+
answers[key] = {
|
|
74
|
+
_tag: "Classify",
|
|
75
|
+
label: answer.choice,
|
|
76
|
+
probabilities: answer.probabilities,
|
|
77
|
+
confidence: answer.confidence
|
|
78
|
+
};
|
|
79
|
+
break;
|
|
80
|
+
case "score":
|
|
81
|
+
{
|
|
82
|
+
const levels = decision._tag === "Rate" ? decision.criteria : [];
|
|
83
|
+
const probabilities = Object.create(null);
|
|
84
|
+
for (let index = 0; index < levels.length; index++) {
|
|
85
|
+
const probability = answer.probabilities[String(index)];
|
|
86
|
+
if (probability !== undefined) probabilities[levels[index]] = probability;
|
|
87
|
+
}
|
|
88
|
+
answers[key] = {
|
|
89
|
+
_tag: "Rate",
|
|
90
|
+
rating: answer.score,
|
|
91
|
+
probabilities,
|
|
92
|
+
confidence: answer.confidence
|
|
93
|
+
};
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case "noul":
|
|
97
|
+
answers[key] = {
|
|
98
|
+
_tag: "Probability",
|
|
99
|
+
probability: answer.noul
|
|
100
|
+
};
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
answers,
|
|
106
|
+
usage: {
|
|
107
|
+
inputTokens: response.usage.input_tokens,
|
|
108
|
+
outputTokens: response.usage.output_tokens
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* Provides DecisionModel using an existing CloudflareClient.
|
|
116
|
+
*
|
|
117
|
+
* @stability unstable
|
|
118
|
+
* @category layers
|
|
119
|
+
* @since 4.0.0
|
|
120
|
+
*/
|
|
121
|
+
export const layer = options => Layer.effect(DecisionModel.DecisionModel, make(options));
|
|
122
|
+
//# sourceMappingURL=CloudflareDecisionModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareDecisionModel.js","names":[],"sources":["../src/CloudflareDecisionModel.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;AAMA,OAAO,KAAK,aAAa,MAAM,yBAAyB;AACxD,OAAO,KAAK,OAAO,MAAM,iBAAiB;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,SAAS,gBAAgB,QAAQ,uBAAuB;AAYxD;;;;;;;AAOA,OAAO,MAAM,KAAK,GAChB,KAAY,IAEZ,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC;EAAE;AAAK,CAAE,CAAC,CAAC;AAErD;;;;;;;AAOA,OAAO,MAAM,IAAI,gBAAG,MAAM,CAAC,UAAU,CACnC,WACE,OAAkC;EAElC,MAAM,MAAM,GAAG,OAAO,gBAAgB;EACtC,OAAO,OAAO,aAAa,CAAC,IAAI,CAAC;IAC/B,oBAAoB,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,WAAU;MAAE,KAAK;MAAE;IAAS,CAAE;MACtD,MAAM,SAAS,GAA6D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;MAC/F,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QACvD,QAAQ,QAAQ,CAAC,IAAI;UACnB,KAAK,UAAU;YACb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C;cACjE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBAClD,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvD,IAAI,WAAW,KAAK,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,WAAW;cAC3E;cACA,OAAO,CAAC,GAAG,CAAC,GAAG;gBAAE,IAAI,EAAE,MAAM;gBAAE,MAAM,EAAE,MAAM,CAAC,KAAK;gBAAE,aAAa;gBAAE,UAAU,EAAE,MAAM,CAAC;cAAU,CAAE;cACnG;YACF;UACA,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC,GAAG;cAAE,IAAI,EAAE,aAAa;cAAE,WAAW,EAAE,MAAM,CAAC;YAAI,CAAE;YAChE;QACJ;MACF;MACA,OAAO;QACL,OAAO;QACP,KAAK,EAAE;UAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY;UAAE,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC;QAAa;OAC9F;IACH,CAAC;GACF,CAAC;AACJ,CAAC,CACF;AAED;;;;;;;AAOA,OAAO,MAAM,KAAK,GAChB,OAAkC,IAElC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codecs for text and JSON decisions from Cloudflare Clef models.
|
|
3
|
+
*
|
|
4
|
+
* @stability unstable
|
|
5
|
+
* @since 4.0.0
|
|
6
|
+
*/
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
/**
|
|
9
|
+
* A classification question.
|
|
10
|
+
*
|
|
11
|
+
* @stability unstable
|
|
12
|
+
* @category schemas
|
|
13
|
+
* @since 4.0.0
|
|
14
|
+
*/
|
|
15
|
+
export declare const ChoiceQuestion: Schema.Struct<{
|
|
16
|
+
readonly type: Schema.Literal<"choice">;
|
|
17
|
+
readonly instructions: Schema.String;
|
|
18
|
+
readonly criteria: Schema.$Record<Schema.String, Schema.String>;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* An ordered rating question.
|
|
22
|
+
*
|
|
23
|
+
* @stability unstable
|
|
24
|
+
* @category schemas
|
|
25
|
+
* @since 4.0.0
|
|
26
|
+
*/
|
|
27
|
+
export declare const ScoreQuestion: Schema.Struct<{
|
|
28
|
+
readonly type: Schema.Literal<"score">;
|
|
29
|
+
readonly instructions: Schema.String;
|
|
30
|
+
readonly criteria: Schema.$Array<Schema.String>;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* A probability question.
|
|
34
|
+
*
|
|
35
|
+
* @stability unstable
|
|
36
|
+
* @category schemas
|
|
37
|
+
* @since 4.0.0
|
|
38
|
+
*/
|
|
39
|
+
export declare const NoulQuestion: Schema.Struct<{
|
|
40
|
+
readonly type: Schema.Literal<"noul">;
|
|
41
|
+
readonly instructions: Schema.String;
|
|
42
|
+
readonly criteria: Schema.optional<Schema.Struct<{
|
|
43
|
+
readonly false: Schema.String;
|
|
44
|
+
readonly true: Schema.String;
|
|
45
|
+
}>>;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* A Clef classification, rating, or probability question.
|
|
49
|
+
*
|
|
50
|
+
* @stability unstable
|
|
51
|
+
* @category schemas
|
|
52
|
+
* @since 4.0.0
|
|
53
|
+
*/
|
|
54
|
+
export declare const Question: Schema.Union<readonly [Schema.Struct<{
|
|
55
|
+
readonly type: Schema.Literal<"choice">;
|
|
56
|
+
readonly instructions: Schema.String;
|
|
57
|
+
readonly criteria: Schema.$Record<Schema.String, Schema.String>;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly type: Schema.Literal<"score">;
|
|
60
|
+
readonly instructions: Schema.String;
|
|
61
|
+
readonly criteria: Schema.$Array<Schema.String>;
|
|
62
|
+
}>, Schema.Struct<{
|
|
63
|
+
readonly type: Schema.Literal<"noul">;
|
|
64
|
+
readonly instructions: Schema.String;
|
|
65
|
+
readonly criteria: Schema.optional<Schema.Struct<{
|
|
66
|
+
readonly false: Schema.String;
|
|
67
|
+
readonly true: Schema.String;
|
|
68
|
+
}>>;
|
|
69
|
+
}>]>;
|
|
70
|
+
/**
|
|
71
|
+
* A batch of questions about text or JSON state.
|
|
72
|
+
*
|
|
73
|
+
* @stability unstable
|
|
74
|
+
* @category schemas
|
|
75
|
+
* @since 4.0.0
|
|
76
|
+
*/
|
|
77
|
+
export declare const DecisionsRequest: Schema.Struct<{
|
|
78
|
+
readonly model: Schema.Union<readonly [Schema.Literals<readonly ["clef", "clef-flash"]>, Schema.StringForLiteralAutocomplete]>;
|
|
79
|
+
readonly state: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
80
|
+
readonly questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
|
|
81
|
+
readonly type: Schema.Literal<"choice">;
|
|
82
|
+
readonly instructions: Schema.String;
|
|
83
|
+
readonly criteria: Schema.$Record<Schema.String, Schema.String>;
|
|
84
|
+
}>, Schema.Struct<{
|
|
85
|
+
readonly type: Schema.Literal<"score">;
|
|
86
|
+
readonly instructions: Schema.String;
|
|
87
|
+
readonly criteria: Schema.$Array<Schema.String>;
|
|
88
|
+
}>, Schema.Struct<{
|
|
89
|
+
readonly type: Schema.Literal<"noul">;
|
|
90
|
+
readonly instructions: Schema.String;
|
|
91
|
+
readonly criteria: Schema.optional<Schema.Struct<{
|
|
92
|
+
readonly false: Schema.String;
|
|
93
|
+
readonly true: Schema.String;
|
|
94
|
+
}>>;
|
|
95
|
+
}>]>>;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* A classification distribution.
|
|
99
|
+
*
|
|
100
|
+
* @stability unstable
|
|
101
|
+
* @category schemas
|
|
102
|
+
* @since 4.0.0
|
|
103
|
+
*/
|
|
104
|
+
export declare const ChoiceAnswer: Schema.Struct<{
|
|
105
|
+
readonly type: Schema.Literal<"choice">;
|
|
106
|
+
readonly choice: Schema.String;
|
|
107
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
108
|
+
readonly confidence: Schema.Number;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* A zero-based rating and index-keyed distribution.
|
|
112
|
+
*
|
|
113
|
+
* @stability unstable
|
|
114
|
+
* @category schemas
|
|
115
|
+
* @since 4.0.0
|
|
116
|
+
*/
|
|
117
|
+
export declare const ScoreAnswer: Schema.Struct<{
|
|
118
|
+
readonly type: Schema.Literal<"score">;
|
|
119
|
+
readonly score: Schema.Number;
|
|
120
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
121
|
+
readonly confidence: Schema.Number;
|
|
122
|
+
readonly legend: Schema.$Record<Schema.String, Schema.String>;
|
|
123
|
+
}>;
|
|
124
|
+
/**
|
|
125
|
+
* A Bernoulli probability.
|
|
126
|
+
*
|
|
127
|
+
* @stability unstable
|
|
128
|
+
* @category schemas
|
|
129
|
+
* @since 4.0.0
|
|
130
|
+
*/
|
|
131
|
+
export declare const NoulAnswer: Schema.Struct<{
|
|
132
|
+
readonly type: Schema.Literal<"noul">;
|
|
133
|
+
readonly noul: Schema.Number;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* A Clef classification, rating, or probability answer.
|
|
137
|
+
*
|
|
138
|
+
* @stability unstable
|
|
139
|
+
* @category schemas
|
|
140
|
+
* @since 4.0.0
|
|
141
|
+
*/
|
|
142
|
+
export declare const Answer: Schema.Union<readonly [Schema.Struct<{
|
|
143
|
+
readonly type: Schema.Literal<"choice">;
|
|
144
|
+
readonly choice: Schema.String;
|
|
145
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
146
|
+
readonly confidence: Schema.Number;
|
|
147
|
+
}>, Schema.Struct<{
|
|
148
|
+
readonly type: Schema.Literal<"score">;
|
|
149
|
+
readonly score: Schema.Number;
|
|
150
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
151
|
+
readonly confidence: Schema.Number;
|
|
152
|
+
readonly legend: Schema.$Record<Schema.String, Schema.String>;
|
|
153
|
+
}>, Schema.Struct<{
|
|
154
|
+
readonly type: Schema.Literal<"noul">;
|
|
155
|
+
readonly noul: Schema.Number;
|
|
156
|
+
}>]>;
|
|
157
|
+
/**
|
|
158
|
+
* Answers and token usage for a batch.
|
|
159
|
+
*
|
|
160
|
+
* @stability unstable
|
|
161
|
+
* @category schemas
|
|
162
|
+
* @since 4.0.0
|
|
163
|
+
*/
|
|
164
|
+
export declare const DecisionsResponse: Schema.Struct<{
|
|
165
|
+
readonly model: Schema.String;
|
|
166
|
+
readonly answers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
|
|
167
|
+
readonly type: Schema.Literal<"choice">;
|
|
168
|
+
readonly choice: Schema.String;
|
|
169
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
170
|
+
readonly confidence: Schema.Number;
|
|
171
|
+
}>, Schema.Struct<{
|
|
172
|
+
readonly type: Schema.Literal<"score">;
|
|
173
|
+
readonly score: Schema.Number;
|
|
174
|
+
readonly probabilities: Schema.$Record<Schema.String, Schema.Number>;
|
|
175
|
+
readonly confidence: Schema.Number;
|
|
176
|
+
readonly legend: Schema.$Record<Schema.String, Schema.String>;
|
|
177
|
+
}>, Schema.Struct<{
|
|
178
|
+
readonly type: Schema.Literal<"noul">;
|
|
179
|
+
readonly noul: Schema.Number;
|
|
180
|
+
}>]>>;
|
|
181
|
+
readonly usage: Schema.Struct<{
|
|
182
|
+
readonly input_tokens: Schema.Int;
|
|
183
|
+
readonly output_tokens: Schema.Int;
|
|
184
|
+
}>;
|
|
185
|
+
}>;
|
|
186
|
+
//# sourceMappingURL=CloudflareSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareSchema.d.ts","sourceRoot":"","sources":["../src/CloudflareSchema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;EAIzB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;EAIxB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;EAIvB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;IAA8D,CAAA;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;EAI3B,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;EAKvB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;;EAMtB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;;;EAAuE,CAAA;AAE9F;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;IAAwD,CAAA;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAA"}
|