@chainfuse/ai-tools 0.1.0 → 0.1.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 +40 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,12 +6,48 @@
|
|
|
6
6
|
|
|
7
7
|
# `@chainfuse/ai-tools`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Vercel AI SDK plugin for multi-model and provider selection built for edge runtimes. Just replace `model` property and continue using vercel ai sdk as normal.
|
|
10
|
+
|
|
11
|
+
## Compatability
|
|
12
|
+
|
|
13
|
+
- [x] `generateText()`
|
|
14
|
+
- [x] `streamText()`
|
|
15
|
+
- [x] `generateObject()`
|
|
16
|
+
- [x] `streamObject()`
|
|
17
|
+
- [x] `embed()`
|
|
18
|
+
- [ ] `generateImage()`
|
|
10
19
|
|
|
11
20
|
## Usage
|
|
12
21
|
|
|
13
|
-
```
|
|
14
|
-
import
|
|
22
|
+
```ts
|
|
23
|
+
import { AiModels } from '@chainfuse/types';
|
|
24
|
+
import { generateText } from 'ai';
|
|
25
|
+
import { AiModel } from '@chainfuse/ai-tools';
|
|
26
|
+
|
|
27
|
+
generateText({
|
|
28
|
+
model: await new AiModel(
|
|
29
|
+
{
|
|
30
|
+
gateway: {
|
|
31
|
+
accountId: 'cf account id',
|
|
32
|
+
apiToken: 'cf ai gateway token with run permission',
|
|
33
|
+
},
|
|
34
|
+
geoRouting: {
|
|
35
|
+
userCoordinate: {
|
|
36
|
+
lat: 'latitude as a string to preserve 0 placement',
|
|
37
|
+
lon: 'longitude as a string to preserve 0 placement',
|
|
38
|
+
},
|
|
39
|
+
country: 'ISO 3166-1 Alpha 2 country code',
|
|
40
|
+
continent: 'two-letter code of continent',
|
|
41
|
+
},
|
|
42
|
+
environment: 'the gateway to use',
|
|
43
|
+
providers: {
|
|
44
|
+
// api keys and any additional info needed for each service
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
// ...
|
|
48
|
+
).wrappedLanguageModel(args, 'AiModels.LanguageModels enum or service name', 'if no enum, then model name (includes autofill typescript types based on service name)'),
|
|
49
|
+
// ... (anything else vercel)
|
|
50
|
+
});
|
|
15
51
|
|
|
16
|
-
//
|
|
52
|
+
// Continue using vercel ai sdk as normal
|
|
17
53
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/ai-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/ai-tools#readme",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"@cloudflare/workers-types": "^4.20241230.0",
|
|
63
63
|
"openai": "^4.77.3"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "54f874d4afcfc72b7405dca76313fb7c8294b738"
|
|
66
66
|
}
|