@cascadeflow/vercel-ai 0.7.1
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 +37 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +36 -0
- package/dist/index.mjs +9 -0
- package/package.json +138 -0
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @cascadeflow/vercel-ai
|
|
2
|
+
|
|
3
|
+
Integration helpers for using **cascadeflow** with the **Vercel AI SDK**.
|
|
4
|
+
|
|
5
|
+
This package is intentionally thin: it re-exports the Vercel AI SDK integration surface from `@cascadeflow/core` so you can treat it as an explicit integration dependency.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @cascadeflow/core @cascadeflow/vercel-ai ai @ai-sdk/react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Next.js `useChat` drop-in backend (App Router)
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// app/api/chat/route.ts
|
|
17
|
+
import { CascadeAgent } from '@cascadeflow/core';
|
|
18
|
+
import { createChatHandler } from '@cascadeflow/vercel-ai';
|
|
19
|
+
|
|
20
|
+
export const runtime = 'edge';
|
|
21
|
+
|
|
22
|
+
const agent = new CascadeAgent({
|
|
23
|
+
models: [
|
|
24
|
+
{ name: 'gpt-4o-mini', provider: 'openai', cost: 0.00015, apiKey: process.env.OPENAI_API_KEY },
|
|
25
|
+
{ name: 'gpt-4o', provider: 'openai', cost: 0.00625, apiKey: process.env.OPENAI_API_KEY },
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const handler = createChatHandler(agent);
|
|
30
|
+
|
|
31
|
+
export async function POST(req: Request) {
|
|
32
|
+
return handler(req);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
See `examples/vercel-ai-nextjs/` for a complete runnable example.
|
|
37
|
+
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Tool, CascadeAgent } from '@cascadeflow/core';
|
|
2
|
+
export { VercelAI } from '@cascadeflow/core';
|
|
3
|
+
|
|
4
|
+
type VercelAIStreamProtocol = 'data' | 'text';
|
|
5
|
+
interface VercelAIChatHandlerOptions {
|
|
6
|
+
protocol?: VercelAIStreamProtocol;
|
|
7
|
+
stream?: boolean;
|
|
8
|
+
systemPrompt?: string;
|
|
9
|
+
maxTokens?: number;
|
|
10
|
+
temperature?: number;
|
|
11
|
+
tools?: Tool[];
|
|
12
|
+
extra?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
declare const createChatHandler: (agent: CascadeAgent, options?: VercelAIChatHandlerOptions) => (request: Request) => Promise<Response>;
|
|
15
|
+
declare const createCompletionHandler: (agent: CascadeAgent, options?: VercelAIChatHandlerOptions) => (request: Request) => Promise<Response>;
|
|
16
|
+
|
|
17
|
+
export { type VercelAIChatHandlerOptions, type VercelAIStreamProtocol, createChatHandler, createCompletionHandler };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Tool, CascadeAgent } from '@cascadeflow/core';
|
|
2
|
+
export { VercelAI } from '@cascadeflow/core';
|
|
3
|
+
|
|
4
|
+
type VercelAIStreamProtocol = 'data' | 'text';
|
|
5
|
+
interface VercelAIChatHandlerOptions {
|
|
6
|
+
protocol?: VercelAIStreamProtocol;
|
|
7
|
+
stream?: boolean;
|
|
8
|
+
systemPrompt?: string;
|
|
9
|
+
maxTokens?: number;
|
|
10
|
+
temperature?: number;
|
|
11
|
+
tools?: Tool[];
|
|
12
|
+
extra?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
declare const createChatHandler: (agent: CascadeAgent, options?: VercelAIChatHandlerOptions) => (request: Request) => Promise<Response>;
|
|
15
|
+
declare const createCompletionHandler: (agent: CascadeAgent, options?: VercelAIChatHandlerOptions) => (request: Request) => Promise<Response>;
|
|
16
|
+
|
|
17
|
+
export { type VercelAIChatHandlerOptions, type VercelAIStreamProtocol, createChatHandler, createCompletionHandler };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
VercelAI: () => import_core.VercelAI,
|
|
24
|
+
createChatHandler: () => createChatHandler,
|
|
25
|
+
createCompletionHandler: () => createCompletionHandler
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var import_core = require("@cascadeflow/core");
|
|
29
|
+
var createChatHandler = (agent, options = {}) => import_core.VercelAI.createChatHandler(agent, options);
|
|
30
|
+
var createCompletionHandler = (agent, options = {}) => import_core.VercelAI.createCompletionHandler(agent, options);
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
VercelAI,
|
|
34
|
+
createChatHandler,
|
|
35
|
+
createCompletionHandler
|
|
36
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { VercelAI } from "@cascadeflow/core";
|
|
3
|
+
var createChatHandler = (agent, options = {}) => VercelAI.createChatHandler(agent, options);
|
|
4
|
+
var createCompletionHandler = (agent, options = {}) => VercelAI.createCompletionHandler(agent, options);
|
|
5
|
+
export {
|
|
6
|
+
VercelAI,
|
|
7
|
+
createChatHandler,
|
|
8
|
+
createCompletionHandler
|
|
9
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cascadeflow/vercel-ai",
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "cascadeflow integration for the Vercel AI SDK (useChat handlers + provider ecosystem)",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Lemony Inc.",
|
|
7
|
+
"email": "hello@lemony.ai"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/lemony-ai/cascadeflow.git",
|
|
13
|
+
"directory": "packages/integrations/vercel-ai"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
31
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"lint": "eslint src --ext .ts",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"clean": "rm -rf dist"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"cascadeflow",
|
|
39
|
+
"vercel",
|
|
40
|
+
"ai-sdk",
|
|
41
|
+
"useChat",
|
|
42
|
+
"nextjs",
|
|
43
|
+
"edge"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@cascadeflow/core": "workspace:*"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"ai": "^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
50
|
+
"@ai-sdk/react": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
51
|
+
"@ai-sdk/anthropic": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
52
|
+
"@ai-sdk/azure": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
53
|
+
"@ai-sdk/amazon-bedrock": "^4.0.0",
|
|
54
|
+
"@ai-sdk/cerebras": "^2.0.0",
|
|
55
|
+
"@ai-sdk/cohere": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
56
|
+
"@ai-sdk/deepseek": "^2.0.0",
|
|
57
|
+
"@ai-sdk/fireworks": "^2.0.0",
|
|
58
|
+
"@ai-sdk/google": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
59
|
+
"@ai-sdk/google-vertex": "^4.0.0",
|
|
60
|
+
"@ai-sdk/groq": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
61
|
+
"@ai-sdk/mistral": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
62
|
+
"@ai-sdk/openai": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
63
|
+
"@ai-sdk/perplexity": "^3.0.0",
|
|
64
|
+
"@ai-sdk/replicate": "^2.0.0",
|
|
65
|
+
"@ai-sdk/togetherai": "^2.0.0",
|
|
66
|
+
"@ai-sdk/xai": "^1.0.0 || ^2.0.0 || ^3.0.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"ai": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"@ai-sdk/react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@ai-sdk/anthropic": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@ai-sdk/azure": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@ai-sdk/amazon-bedrock": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"@ai-sdk/cerebras": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@ai-sdk/cohere": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"@ai-sdk/deepseek": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"@ai-sdk/fireworks": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@ai-sdk/google": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@ai-sdk/google-vertex": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"@ai-sdk/groq": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"@ai-sdk/mistral": {
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
"@ai-sdk/openai": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"@ai-sdk/perplexity": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"@ai-sdk/replicate": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"@ai-sdk/togetherai": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"@ai-sdk/xai": {
|
|
121
|
+
"optional": true
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"devDependencies": {
|
|
125
|
+
"ai": "^4.0.0",
|
|
126
|
+
"@ai-sdk/react": "^3.0.0",
|
|
127
|
+
"@types/node": "^20.10.0",
|
|
128
|
+
"tsup": "^8.5.1",
|
|
129
|
+
"typescript": "^5.3.3",
|
|
130
|
+
"vitest": "^1.6.1"
|
|
131
|
+
},
|
|
132
|
+
"publishConfig": {
|
|
133
|
+
"access": "public"
|
|
134
|
+
},
|
|
135
|
+
"engines": {
|
|
136
|
+
"node": ">=18.0.0"
|
|
137
|
+
}
|
|
138
|
+
}
|