@krutai/ai-provider 0.2.1 → 0.2.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/AI_REFERENCE.md +7 -6
- package/README.md +7 -7
- package/package.json +1 -1
package/AI_REFERENCE.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Package Overview
|
|
4
4
|
|
|
5
5
|
- **Name**: `@krutai/ai-provider`
|
|
6
|
-
- **Version**: `0.2.
|
|
6
|
+
- **Version**: `0.2.2`
|
|
7
7
|
- **Purpose**: AI provider for KrutAI — fetch-based client for your deployed LangChain server with API key validation
|
|
8
8
|
- **Entry**: `src/index.ts` → `dist/index.{js,mjs,d.ts}`
|
|
9
9
|
- **Build**: `tsup` (CJS + ESM, no external SDK deps)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
## Architecture
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
@krutai/ai-provider@0.2.
|
|
14
|
+
@krutai/ai-provider@0.2.2
|
|
15
15
|
└── peerDep: krutai (core utilities)
|
|
16
16
|
|
|
17
17
|
AI Flow:
|
|
@@ -57,7 +57,8 @@ import { krutAI } from '@krutai/ai-provider';
|
|
|
57
57
|
|
|
58
58
|
const ai = krutAI({
|
|
59
59
|
apiKey: process.env.KRUTAI_API_KEY!,
|
|
60
|
-
|
|
60
|
+
// uses http://localhost:8000 by default for local development
|
|
61
|
+
// serverUrl: 'https://ai.yourapp.com',
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
await ai.initialize(); // validates key with server
|
|
@@ -72,7 +73,7 @@ import { KrutAIProvider } from '@krutai/ai-provider';
|
|
|
72
73
|
|
|
73
74
|
const ai = new KrutAIProvider({
|
|
74
75
|
apiKey: process.env.KRUTAI_API_KEY!,
|
|
75
|
-
serverUrl: 'https://ai.yourapp.com',
|
|
76
|
+
// serverUrl: 'https://ai.yourapp.com', // Optional: defaults to localhost:8000
|
|
76
77
|
model: 'gpt-4o', // optional, default: 'default'
|
|
77
78
|
validateOnInit: true, // default: true
|
|
78
79
|
});
|
|
@@ -95,7 +96,7 @@ await ai.initialize();
|
|
|
95
96
|
```typescript
|
|
96
97
|
interface KrutAIProviderConfig {
|
|
97
98
|
apiKey: string; // KrutAI API key — validated with server (required)
|
|
98
|
-
serverUrl
|
|
99
|
+
serverUrl?: string; // Base URL of deployed LangChain server (default: 'http://localhost:8000')
|
|
99
100
|
model?: string; // default: 'default'
|
|
100
101
|
validateOnInit?: boolean; // default: true
|
|
101
102
|
}
|
|
@@ -141,7 +142,7 @@ export { validateApiKey, validateApiKeyFormat, KrutAIKeyValidationError };
|
|
|
141
142
|
|
|
142
143
|
## Important Notes
|
|
143
144
|
|
|
144
|
-
1. **`serverUrl`
|
|
145
|
+
1. **`serverUrl` defaults to `http://localhost:8000`** — make sure to override this with your deployed LangChain backend in production
|
|
145
146
|
2. **`apiKey` is validated server-side** — the server controls what keys are valid
|
|
146
147
|
3. **Streaming uses SSE** — server must respond with `Content-Type: text/event-stream`
|
|
147
148
|
4. **No external SDK needed** — uses native `fetch` only (Node 18+, browser, edge runtimes)
|
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@ import { krutAI } from '@krutai/ai-provider';
|
|
|
23
23
|
|
|
24
24
|
const ai = krutAI({
|
|
25
25
|
apiKey: 'your-krutai-api-key',
|
|
26
|
-
|
|
26
|
+
// Optional: omitted to use the default local dev server ('http://localhost:8000')
|
|
27
|
+
// serverUrl: 'https://ai.yourapp.com',
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
await ai.initialize(); // validates key with your server
|
|
@@ -40,7 +41,7 @@ console.log(text);
|
|
|
40
41
|
```typescript
|
|
41
42
|
const ai = krutAI({
|
|
42
43
|
apiKey: process.env.KRUTAI_API_KEY!,
|
|
43
|
-
serverUrl: 'https://ai.yourapp.com',
|
|
44
|
+
serverUrl: 'https://ai.yourapp.com', // Override default for production
|
|
44
45
|
model: 'gpt-4o', // optional — server's default is used if omitted
|
|
45
46
|
});
|
|
46
47
|
|
|
@@ -60,7 +61,7 @@ console.log(text);
|
|
|
60
61
|
```typescript
|
|
61
62
|
const ai = krutAI({
|
|
62
63
|
apiKey: process.env.KRUTAI_API_KEY!,
|
|
63
|
-
|
|
64
|
+
// uses http://localhost:8000 by default
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
await ai.initialize();
|
|
@@ -76,7 +77,6 @@ for await (const chunk of ai.stream('Tell me a short story')) {
|
|
|
76
77
|
```typescript
|
|
77
78
|
const ai = krutAI({
|
|
78
79
|
apiKey: process.env.KRUTAI_API_KEY!,
|
|
79
|
-
serverUrl: 'https://ai.yourapp.com',
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
await ai.initialize();
|
|
@@ -129,9 +129,9 @@ Factory function — preferred way to create a provider.
|
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
131
|
const ai = krutAI({
|
|
132
|
-
apiKey: string;
|
|
133
|
-
serverUrl
|
|
134
|
-
model?: string;
|
|
132
|
+
apiKey: string; // required — KrutAI API key
|
|
133
|
+
serverUrl?: string; // optional — defaults to 'http://localhost:8000'
|
|
134
|
+
model?: string; // optional — passed to server (default: 'default')
|
|
135
135
|
validateOnInit?: boolean; // optional — default: true
|
|
136
136
|
});
|
|
137
137
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krutai/ai-provider",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "AI provider package for KrutAI — fetch-based client for your deployed LangChain server with API key validation",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|