@ax-llm/ax-ai-sdk-provider 19.0.38 → 19.0.40
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 +75 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
## Vercel AI SDK Integration
|
|
2
|
+
|
|
3
|
+
Install the ax provider package
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm i @ax-llm/ax-ai-sdk-provider
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### AI SDK v5 Compatibility
|
|
10
|
+
|
|
11
|
+
This provider is fully compatible with **AI SDK v5** and implements the `LanguageModelV2` specification. It supports:
|
|
12
|
+
|
|
13
|
+
- ✅ **Text Generation**: Standard text completion and chat functionality
|
|
14
|
+
- ✅ **Tool Calling**: Function calls with proper serialization/deserialization
|
|
15
|
+
- ✅ **Streaming**: Enhanced streaming with proper lifecycle events (`stream-start`, `text-start`, `text-delta`, `text-end`, `finish`)
|
|
16
|
+
- ✅ **Multi-modal**: Support for text and file inputs (images, documents)
|
|
17
|
+
- ✅ **Token Usage**: Accurate tracking with `inputTokens`, `outputTokens`, and `totalTokens`
|
|
18
|
+
|
|
19
|
+
> **Note**: If you're upgrading from AI SDK v4, this provider handles all the necessary conversions between v1 and v2 specification formats automatically.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
You can use it with the AI SDK, either with the AI provider or the Agent Provider
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const ai = new AxAI({
|
|
27
|
+
name: "openai",
|
|
28
|
+
apiKey: process.env["OPENAI_APIKEY"] ?? "",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Create a model using the provider
|
|
32
|
+
const model = new AxAIProvider(ai);
|
|
33
|
+
|
|
34
|
+
export const foodAgent = new AxAgent({
|
|
35
|
+
name: "food-search",
|
|
36
|
+
description:
|
|
37
|
+
"Use this agent to find restaurants based on what the customer wants",
|
|
38
|
+
signature,
|
|
39
|
+
functions,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Get vercel ai sdk state
|
|
43
|
+
const aiState = getMutableAIState();
|
|
44
|
+
|
|
45
|
+
// Create an agent for a specific task
|
|
46
|
+
const foodAgent = new AxAgentProvider(ai, {
|
|
47
|
+
agent: foodAgent,
|
|
48
|
+
updateState: (state) => {
|
|
49
|
+
aiState.done({ ...aiState.get(), state });
|
|
50
|
+
},
|
|
51
|
+
generate: async ({ restaurant, priceRange }) => {
|
|
52
|
+
return (
|
|
53
|
+
<BotCard>
|
|
54
|
+
<h1>{restaurant as string} {priceRange as string}</h1>
|
|
55
|
+
</BotCard>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Use with streamUI a critical part of building chat UIs in the AI SDK
|
|
61
|
+
const result = await streamUI({
|
|
62
|
+
model,
|
|
63
|
+
initial: <SpinnerMessage />,
|
|
64
|
+
messages: [
|
|
65
|
+
// ...
|
|
66
|
+
],
|
|
67
|
+
text: ({ content, done, delta }) => {
|
|
68
|
+
// ...
|
|
69
|
+
},
|
|
70
|
+
tools: {
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
"find-food": foodAgent,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ax-llm/ax-ai-sdk-provider",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ax AI SDK Provider for the Vercel AI SDK",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"keywords": [],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@ai-sdk/provider-utils": "^3.0.10",
|
|
17
|
-
"@ax-llm/ax": "19.0.
|
|
17
|
+
"@ax-llm/ax": "19.0.40",
|
|
18
18
|
"ai": "^5.0.100",
|
|
19
19
|
"zod": "^3.23.8"
|
|
20
20
|
},
|