@rudra-js/anthropic 0.1.0 → 0.2.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 +32 -3
- package/dist/anthropic-provider.d.ts +2 -2
- package/dist/anthropic-provider.js +2 -2
- package/package.json +4 -4
- package/src/anthropic-provider.ts +2 -2
package/README.md
CHANGED
|
@@ -4,10 +4,13 @@ An Anthropic adapter for
|
|
|
4
4
|
[`@rudra-js/core`](https://github.com/clivedsouza1010/rudra-js/tree/main/packages/core)'s
|
|
5
5
|
`ComponentProvider`.
|
|
6
6
|
|
|
7
|
+
> Anthropic and Claude are trademarks of Anthropic, PBC. This package is an
|
|
8
|
+
> independent adapter and is not affiliated with or endorsed by Anthropic.
|
|
9
|
+
|
|
7
10
|
## Install
|
|
8
11
|
|
|
9
12
|
```sh
|
|
10
|
-
npm install @rudra-js/anthropic @rudra-js/core zod
|
|
13
|
+
npm install @rudra-js/anthropic @rudra-js/core zod@^4
|
|
11
14
|
```
|
|
12
15
|
|
|
13
16
|
```ts
|
|
@@ -18,8 +21,9 @@ const provider = createAnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY
|
|
|
18
21
|
const generator = createComponentGenerator({ provider });
|
|
19
22
|
```
|
|
20
23
|
|
|
21
|
-
`model` defaults to the
|
|
22
|
-
pass it to pin a different one. `maxTokens` and `baseUrl` are also
|
|
24
|
+
`model` defaults to `claude-opus-5`, the Claude model this package was written
|
|
25
|
+
against; pass it to pin a different one. `maxTokens` and `baseUrl` are also
|
|
26
|
+
optional.
|
|
23
27
|
|
|
24
28
|
### An identity-linked key needs a workspace
|
|
25
29
|
|
|
@@ -49,6 +53,31 @@ The tool schema sent to the model is derived from the `schema` on the
|
|
|
49
53
|
copy written out here. A second copy would be a second vocabulary: the
|
|
50
54
|
reconciler would enforce one thing and the model would be told another.
|
|
51
55
|
|
|
56
|
+
## Data handling
|
|
57
|
+
|
|
58
|
+
Each generation is one POST to `https://api.anthropic.com/v1/messages`. Set
|
|
59
|
+
`baseUrl` and it goes to that host instead — a proxy, a gateway, or a
|
|
60
|
+
region-specific endpoint you have.
|
|
61
|
+
|
|
62
|
+
What is in that request is listed under **What the model sees** in the
|
|
63
|
+
[`@rudra-js/core` README](https://github.com/clivedsouza1010/rudra-js/tree/main/packages/core#what-the-model-sees).
|
|
64
|
+
Read it before you send real shopper traffic. In cohort mode, the default, the
|
|
65
|
+
request carries no individual. In per-shopper mode it carries that shopper's
|
|
66
|
+
likes, dislikes, purchases, basket, views and recent searches.
|
|
67
|
+
|
|
68
|
+
If your shop is in the EU or the UK, you are the one sending personal data to
|
|
69
|
+
Anthropic, and you need a data processing agreement with them plus a transfer
|
|
70
|
+
mechanism for the data leaving your region. Your shop is Anthropic's customer;
|
|
71
|
+
this package is a piece of code in the middle and is not a party to anything.
|
|
72
|
+
|
|
73
|
+
When the API answers with an error, the thrown `Error` carries the status code
|
|
74
|
+
and the vendor's error category — `anthropic responded 400
|
|
75
|
+
(invalid_request_error)`. The vendor's own message is left out on purpose: it
|
|
76
|
+
quotes the request back, and for this framework the request can hold a shopper's
|
|
77
|
+
search terms, which an adopter's `console.error(error)` would then write to a
|
|
78
|
+
log. A test in `anthropic-provider.test.ts` puts a search term in that message
|
|
79
|
+
and asserts it does not reach the thrown error.
|
|
80
|
+
|
|
52
81
|
## Licence
|
|
53
82
|
|
|
54
83
|
[MIT](./LICENSE)
|
|
@@ -18,8 +18,8 @@ export interface AnthropicProviderOptions {
|
|
|
18
18
|
* Adapts the Anthropic Messages API to `ComponentProvider`.
|
|
19
19
|
*
|
|
20
20
|
* The tool schema is derived from the schema core exports rather than restated
|
|
21
|
-
* here: a second copy is a second vocabulary, and the drift
|
|
22
|
-
*
|
|
21
|
+
* here: a second copy is a second vocabulary, and the drift would throw below
|
|
22
|
+
* and reach the generator as `provider-error` events.
|
|
23
23
|
*/
|
|
24
24
|
export declare function createAnthropicProvider(options: AnthropicProviderOptions): ComponentProvider;
|
|
25
25
|
//# sourceMappingURL=anthropic-provider.d.ts.map
|
|
@@ -33,8 +33,8 @@ function isToolUseBlock(candidate) {
|
|
|
33
33
|
* Adapts the Anthropic Messages API to `ComponentProvider`.
|
|
34
34
|
*
|
|
35
35
|
* The tool schema is derived from the schema core exports rather than restated
|
|
36
|
-
* here: a second copy is a second vocabulary, and the drift
|
|
37
|
-
*
|
|
36
|
+
* here: a second copy is a second vocabulary, and the drift would throw below
|
|
37
|
+
* and reach the generator as `provider-error` events.
|
|
38
38
|
*/
|
|
39
39
|
export function createAnthropicProvider(options) {
|
|
40
40
|
const model = options.model ?? 'claude-opus-5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rudra-js/anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "An Anthropic adapter for @rudra-js/core, with no vendor SDK and no dependencies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anthropic",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"directory": "packages/anthropic"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": "
|
|
24
|
+
"node": ">=22.12.0"
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
27
|
"main": "./dist/index.js",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@rudra-js/core": "^0.
|
|
51
|
-
"zod": "^4.5.
|
|
50
|
+
"@rudra-js/core": "^0.2.0",
|
|
51
|
+
"zod": "^4.5.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@rudra-js/core": "0.1.0",
|
|
@@ -66,8 +66,8 @@ function isToolUseBlock(candidate: unknown): candidate is ToolUseBlock {
|
|
|
66
66
|
* Adapts the Anthropic Messages API to `ComponentProvider`.
|
|
67
67
|
*
|
|
68
68
|
* The tool schema is derived from the schema core exports rather than restated
|
|
69
|
-
* here: a second copy is a second vocabulary, and the drift
|
|
70
|
-
*
|
|
69
|
+
* here: a second copy is a second vocabulary, and the drift would throw below
|
|
70
|
+
* and reach the generator as `provider-error` events.
|
|
71
71
|
*/
|
|
72
72
|
export function createAnthropicProvider(options: AnthropicProviderOptions): ComponentProvider {
|
|
73
73
|
const model = options.model ?? 'claude-opus-5';
|