@effect/ai-cloudflare 0.0.0-stage → 0.0.0
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/README.md +43 -2
- package/package.json +21 -4
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @effect/ai-cloudflare
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cloudflare Workers AI provider for Effect's `DecisionModel`. Supports text and JSON classification, ordered ratings, and probabilities with Clef and Clef-flash over REST.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install effect @effect/ai-cloudflare
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Set `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`, then provide a Cloudflare decision model:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { CloudflareClient, CloudflareDecisionModel } from "@effect/ai-cloudflare"
|
|
17
|
+
import { Effect, Layer, Schema } from "effect"
|
|
18
|
+
import { Decision, DecisionModel } from "effect/ai"
|
|
19
|
+
import { FetchHttpClient } from "effect/http"
|
|
20
|
+
|
|
21
|
+
const Triage = Decision.make({
|
|
22
|
+
input: Schema.String,
|
|
23
|
+
decisions: {
|
|
24
|
+
urgent: Decision.probability({
|
|
25
|
+
instructions: "Does this request need immediate attention?"
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const Clef = CloudflareDecisionModel.layer({ model: "clef-flash" }).pipe(
|
|
31
|
+
Layer.provide(CloudflareClient.layerConfig()),
|
|
32
|
+
Layer.provide(FetchHttpClient.layer)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const program = DecisionModel.decide(Triage, {
|
|
36
|
+
input: "Checkout has been failing for every customer for an hour."
|
|
37
|
+
}).pipe(Effect.provide(Clef))
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use `"clef"` for the larger model. `CloudflareDecisionModel.model` provides a model descriptor with Cloudflare provider metadata. `CloudflareClient.layer` accepts an explicit account ID and redacted API token; `apiUrl` and `transformClient` customize HTTP access.
|
|
41
|
+
|
|
42
|
+
The client unwraps Cloudflare's REST envelope and maps failures to `AiError`. It does not retry automatically. Rate-limit errors include `Retry-After` when provided. The decision model validates answers and rescales small probability drift from four-decimal rounding.
|
|
43
|
+
|
|
44
|
+
Cloudflare limits each request to 64 questions, classification to 2–255 choices, and ratings to 2–10 levels. See the [Clef API documentation](https://developers.cloudflare.com/workers-ai/models/clef/) for request limits.
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/ai-cloudflare",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "OIDC trusted publishing setup package for @effect/ai-cloudflare",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"oidc",
|
|
7
|
+
"trusted-publishing",
|
|
8
|
+
"setup"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"homepage": "https://effect.website",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/Effect-TS/effect.git",
|
|
15
|
+
"directory": "packages/ai/cloudflare"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/Effect-TS/effect/issues"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|