@molecule/api-ai-anthropic 1.3.1 → 1.3.2
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 +21 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-01T18:20:43.990Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-anthropic
|
|
@@ -14,6 +14,26 @@ Generated: 2026-09-23T14:02:08.567Z
|
|
|
14
14
|
|
|
15
15
|
Anthropic ai-anthropic provider for molecule.dev.
|
|
16
16
|
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// npm install @molecule/api-ai-anthropic --workspace=api
|
|
21
|
+
import { setProvider, requireProvider } from '@molecule/api-ai'
|
|
22
|
+
import { provider } from '@molecule/api-ai-anthropic'
|
|
23
|
+
|
|
24
|
+
// Named registration — several AI providers can be bonded side by side
|
|
25
|
+
// (getProviderByName('anthropic') targets this one); the FIRST one
|
|
26
|
+
// registered also answers requireProvider() (see @molecule/api-ai).
|
|
27
|
+
setProvider('anthropic', provider) // reads ANTHROPIC_API_KEY from the environment
|
|
28
|
+
|
|
29
|
+
let reply = ''
|
|
30
|
+
for await (const event of requireProvider().chat({
|
|
31
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
32
|
+
})) {
|
|
33
|
+
if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
17
37
|
## Type
|
|
18
38
|
|
|
19
39
|
`provider`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anthropic ai-anthropic provider for molecule.dev.
|
|
3
3
|
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* // npm install @molecule/api-ai-anthropic --workspace=api
|
|
7
|
+
* import { setProvider, requireProvider } from '@molecule/api-ai'
|
|
8
|
+
* import { provider } from '@molecule/api-ai-anthropic'
|
|
9
|
+
*
|
|
10
|
+
* // Named registration — several AI providers can be bonded side by side
|
|
11
|
+
* // (getProviderByName('anthropic') targets this one); the FIRST one
|
|
12
|
+
* // registered also answers requireProvider() (see @molecule/api-ai).
|
|
13
|
+
* setProvider('anthropic', provider) // reads ANTHROPIC_API_KEY from the environment
|
|
14
|
+
*
|
|
15
|
+
* let reply = ''
|
|
16
|
+
* for await (const event of requireProvider().chat({
|
|
17
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
18
|
+
* })) {
|
|
19
|
+
* if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
4
23
|
* @remarks
|
|
5
24
|
* Bond this as an AI provider (see `@molecule/api-ai` for the `chat()` streaming loop and the
|
|
6
25
|
* key-server-side / never-blindly-trust-model-output rules). Config: `ANTHROPIC_API_KEY`
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAMlD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAUrB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anthropic ai-anthropic provider for molecule.dev.
|
|
3
3
|
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* // npm install @molecule/api-ai-anthropic --workspace=api
|
|
7
|
+
* import { setProvider, requireProvider } from '@molecule/api-ai'
|
|
8
|
+
* import { provider } from '@molecule/api-ai-anthropic'
|
|
9
|
+
*
|
|
10
|
+
* // Named registration — several AI providers can be bonded side by side
|
|
11
|
+
* // (getProviderByName('anthropic') targets this one); the FIRST one
|
|
12
|
+
* // registered also answers requireProvider() (see @molecule/api-ai).
|
|
13
|
+
* setProvider('anthropic', provider) // reads ANTHROPIC_API_KEY from the environment
|
|
14
|
+
*
|
|
15
|
+
* let reply = ''
|
|
16
|
+
* for await (const event of requireProvider().chat({
|
|
17
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
18
|
+
* })) {
|
|
19
|
+
* if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
4
23
|
* @remarks
|
|
5
24
|
* Bond this as an AI provider (see `@molecule/api-ai` for the `chat()` streaming loop and the
|
|
6
25
|
* key-server-side / never-blindly-trust-model-output rules). Config: `ANTHROPIC_API_KEY`
|
package/package.json
CHANGED