@providerprotocol/ai 0.0.36 → 0.0.38
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 +28 -0
- package/dist/anthropic/index.d.ts +2 -2
- package/dist/anthropic/index.js +12 -10
- package/dist/anthropic/index.js.map +1 -1
- package/dist/cerebras/index.d.ts +2 -2
- package/dist/cerebras/index.js +12 -10
- package/dist/cerebras/index.js.map +1 -1
- package/dist/{chunk-UFFJDYCE.js → chunk-7GTWHZY2.js} +2 -2
- package/dist/{chunk-IDZOVWP3.js → chunk-BDXH6NQS.js} +9 -9
- package/dist/{chunk-OIEWDFQU.js → chunk-FYSZFIZS.js} +2 -2
- package/dist/chunk-GIDT7C6I.js +37 -0
- package/dist/chunk-GIDT7C6I.js.map +1 -0
- package/dist/{chunk-VGKZIGVI.js → chunk-LTEMH3CI.js} +2 -2
- package/dist/{chunk-RJGTRQ47.js → chunk-MJI74VEJ.js} +6 -1
- package/dist/chunk-MJI74VEJ.js.map +1 -0
- package/dist/{chunk-AY55T37A.js → chunk-SBGZJVTJ.js} +4 -30
- package/dist/chunk-SBGZJVTJ.js.map +1 -0
- package/dist/{chunk-A2IM7PGT.js → chunk-TUTYMOBL.js} +2 -2
- package/dist/{chunk-BRP5XJ6Q.js → chunk-WU4U6IHF.js} +2 -2
- package/dist/chunk-WU4U6IHF.js.map +1 -0
- package/dist/{chunk-C4JP64VW.js → chunk-YQLR3XOA.js} +2 -2
- package/dist/chunk-ZKNPQBIE.js +265 -0
- package/dist/chunk-ZKNPQBIE.js.map +1 -0
- package/dist/{chunk-4OGB7JZA.js → chunk-ZRVNAET3.js} +2 -2
- package/dist/{embedding-BXA72PlJ.d.ts → embedding-CwZ1ZNWv.d.ts} +1 -1
- package/dist/google/index.d.ts +2 -2
- package/dist/google/index.js +12 -10
- package/dist/google/index.js.map +1 -1
- package/dist/groq/index.d.ts +2 -2
- package/dist/groq/index.js +12 -10
- package/dist/groq/index.js.map +1 -1
- package/dist/http/index.d.ts +3 -3
- package/dist/http/index.js +2 -1
- package/dist/{image-stream-CCgwB7ve.d.ts → image-stream-CeQHtjxS.d.ts} +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +86 -283
- package/dist/index.js.map +1 -1
- package/dist/{llm-ByUFPcFH.d.ts → llm-DS_-l71X.d.ts} +11 -3
- package/dist/middleware/logging/index.d.ts +2 -2
- package/dist/middleware/parsed-object/index.d.ts +2 -2
- package/dist/middleware/parsed-object/index.js +1 -1
- package/dist/middleware/persistence/index.d.ts +128 -0
- package/dist/middleware/persistence/index.js +144 -0
- package/dist/middleware/persistence/index.js.map +1 -0
- package/dist/middleware/pubsub/index.d.ts +4 -4
- package/dist/middleware/pubsub/server/express/index.d.ts +2 -2
- package/dist/middleware/pubsub/server/fastify/index.d.ts +2 -2
- package/dist/middleware/pubsub/server/h3/index.d.ts +2 -2
- package/dist/middleware/pubsub/server/index.d.ts +2 -2
- package/dist/middleware/pubsub/server/webapi/index.d.ts +2 -2
- package/dist/moonshot/index.d.ts +510 -0
- package/dist/moonshot/index.js +1090 -0
- package/dist/moonshot/index.js.map +1 -0
- package/dist/ollama/index.d.ts +2 -2
- package/dist/ollama/index.js +12 -10
- package/dist/ollama/index.js.map +1 -1
- package/dist/openai/index.d.ts +2 -2
- package/dist/openai/index.js +12 -10
- package/dist/openai/index.js.map +1 -1
- package/dist/openrouter/index.d.ts +2 -2
- package/dist/openrouter/index.js +12 -10
- package/dist/openrouter/index.js.map +1 -1
- package/dist/proxy/index.d.ts +4 -4
- package/dist/proxy/index.js +22 -20
- package/dist/proxy/index.js.map +1 -1
- package/dist/proxy/server/express/index.d.ts +4 -4
- package/dist/proxy/server/express/index.js +3 -3
- package/dist/proxy/server/fastify/index.d.ts +4 -4
- package/dist/proxy/server/fastify/index.js +3 -3
- package/dist/proxy/server/h3/index.d.ts +4 -4
- package/dist/proxy/server/h3/index.js +3 -3
- package/dist/proxy/server/index.d.ts +4 -4
- package/dist/proxy/server/index.js +11 -11
- package/dist/proxy/server/webapi/index.d.ts +4 -4
- package/dist/proxy/server/webapi/index.js +3 -3
- package/dist/responses/index.d.ts +2 -2
- package/dist/responses/index.js +12 -10
- package/dist/responses/index.js.map +1 -1
- package/dist/{retry-BDMo4AVu.d.ts → retry-CgoBNa51.d.ts} +1 -1
- package/dist/{stream-S7nwQRqM.d.ts → stream-sXhBtWjl.d.ts} +4 -0
- package/dist/{types-CE4B7pno.d.ts → types-Cr4F0tVy.d.ts} +1 -1
- package/dist/xai/index.d.ts +2 -2
- package/dist/xai/index.js +12 -10
- package/dist/xai/index.js.map +1 -1
- package/package.json +13 -1
- package/dist/chunk-AY55T37A.js.map +0 -1
- package/dist/chunk-BRP5XJ6Q.js.map +0 -1
- package/dist/chunk-RJGTRQ47.js.map +0 -1
- /package/dist/{chunk-UFFJDYCE.js.map → chunk-7GTWHZY2.js.map} +0 -0
- /package/dist/{chunk-IDZOVWP3.js.map → chunk-BDXH6NQS.js.map} +0 -0
- /package/dist/{chunk-OIEWDFQU.js.map → chunk-FYSZFIZS.js.map} +0 -0
- /package/dist/{chunk-VGKZIGVI.js.map → chunk-LTEMH3CI.js.map} +0 -0
- /package/dist/{chunk-A2IM7PGT.js.map → chunk-TUTYMOBL.js.map} +0 -0
- /package/dist/{chunk-C4JP64VW.js.map → chunk-YQLR3XOA.js.map} +0 -0
- /package/dist/{chunk-4OGB7JZA.js.map → chunk-ZRVNAET3.js.map} +0 -0
package/README.md
CHANGED
|
@@ -646,6 +646,34 @@ const model = llm({
|
|
|
646
646
|
const result = await model.generate('Hello');
|
|
647
647
|
```
|
|
648
648
|
|
|
649
|
+
### Persistence Middleware
|
|
650
|
+
|
|
651
|
+
Load and save conversation threads around LLM requests:
|
|
652
|
+
|
|
653
|
+
```typescript
|
|
654
|
+
import { llm, Thread } from '@providerprotocol/ai';
|
|
655
|
+
import { anthropic } from '@providerprotocol/ai/anthropic';
|
|
656
|
+
import { persistenceMiddleware, PersistenceAdapter } from '@providerprotocol/ai/middleware/persistence';
|
|
657
|
+
|
|
658
|
+
const adapter = new PersistenceAdapter({
|
|
659
|
+
id: 'conversation-123',
|
|
660
|
+
load: async (id) => loadThreadFromDatabase(id), // Thread | ThreadJSON | null
|
|
661
|
+
save: async (id, thread, turn) => {
|
|
662
|
+
await saveThreadToDatabase(id, thread);
|
|
663
|
+
if (turn) {
|
|
664
|
+
await saveTurnToDatabase(id, turn);
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
const model = llm({
|
|
670
|
+
model: anthropic('claude-sonnet-4-20250514'),
|
|
671
|
+
middleware: [persistenceMiddleware({ adapter })],
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
const turn = await model.generate('Hello!');
|
|
675
|
+
```
|
|
676
|
+
|
|
649
677
|
### Pub-Sub Middleware (Stream Resumption)
|
|
650
678
|
|
|
651
679
|
Enable reconnecting clients to catch up on missed events during active generation. The middleware buffers events, publishes them to subscribers, and removes streams on completion/abort/error.
|
package/dist/anthropic/index.js
CHANGED
|
@@ -3,35 +3,37 @@ import {
|
|
|
3
3
|
} from "../chunk-PMK5LZ5Z.js";
|
|
4
4
|
import {
|
|
5
5
|
parseJsonResponse
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-TUTYMOBL.js";
|
|
7
7
|
import {
|
|
8
8
|
resolveApiKey
|
|
9
9
|
} from "../chunk-ARVM24K2.js";
|
|
10
10
|
import {
|
|
11
11
|
createProvider
|
|
12
12
|
} from "../chunk-JA3UZALR.js";
|
|
13
|
+
import {
|
|
14
|
+
doFetch,
|
|
15
|
+
doStreamFetch,
|
|
16
|
+
normalizeHttpError
|
|
17
|
+
} from "../chunk-SBGZJVTJ.js";
|
|
18
|
+
import {
|
|
19
|
+
StreamEventType,
|
|
20
|
+
objectDelta
|
|
21
|
+
} from "../chunk-MJI74VEJ.js";
|
|
13
22
|
import {
|
|
14
23
|
AssistantMessage,
|
|
15
24
|
generateId,
|
|
16
25
|
isAssistantMessage,
|
|
17
26
|
isToolResultMessage,
|
|
18
27
|
isUserMessage
|
|
19
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-WU4U6IHF.js";
|
|
20
29
|
import {
|
|
21
|
-
doFetch,
|
|
22
|
-
doStreamFetch,
|
|
23
|
-
normalizeHttpError,
|
|
24
30
|
toError
|
|
25
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-GIDT7C6I.js";
|
|
26
32
|
import {
|
|
27
33
|
ErrorCode,
|
|
28
34
|
ModalityType,
|
|
29
35
|
UPPError
|
|
30
36
|
} from "../chunk-COS4ON4G.js";
|
|
31
|
-
import {
|
|
32
|
-
StreamEventType,
|
|
33
|
-
objectDelta
|
|
34
|
-
} from "../chunk-RJGTRQ47.js";
|
|
35
37
|
|
|
36
38
|
// src/providers/anthropic/types.ts
|
|
37
39
|
var betas = {
|