web-ai-service 1.0.0 β 1.0.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 +343 -135
- package/dist/engine/config/llm-costs.d.ts.map +1 -1
- package/dist/engine/config/llm-costs.js +14 -0
- package/dist/engine/config/llm-costs.js.map +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +4 -0
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/providers/anthropic.d.ts +27 -0
- package/dist/engine/providers/anthropic.d.ts.map +1 -0
- package/dist/engine/providers/anthropic.js +143 -0
- package/dist/engine/providers/anthropic.js.map +1 -0
- package/dist/engine/providers/openai.d.ts +27 -0
- package/dist/engine/providers/openai.d.ts.map +1 -0
- package/dist/engine/providers/openai.js +143 -0
- package/dist/engine/providers/openai.js.map +1 -0
- package/dist/engine/types/index.d.ts +2 -2
- package/dist/engine/types/index.d.ts.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,136 +1,142 @@
|
|
|
1
1
|
# Web AI Service
|
|
2
2
|
|
|
3
|
-
A TypeScript-based workflow engine that creates dynamic API endpoints from YAML workflow definitions. Build powerful
|
|
3
|
+
A TypeScript-based workflow engine that creates dynamic API endpoints from YAML workflow definitions. Build powerful AI-powered APIs with LLM calls, custom code execution, and data transformationsβall without writing server boilerplate.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- π **YAML-Based Configuration** - Define API endpoints declaratively
|
|
8
|
-
- π€ **LLM
|
|
8
|
+
- π€ **Multi-LLM Support** - Built-in support for Gemini, OpenAI, Anthropic, and Grok
|
|
9
9
|
- π **Custom Code Nodes** - Execute TypeScript functions in your workflows
|
|
10
10
|
- β‘ **Parallel Execution** - Run multiple nodes concurrently with error strategies
|
|
11
11
|
- π **Data Transformation** - Reduce, split, and map data with JSONPath
|
|
12
12
|
- β
**Input Validation** - JSON Schema validation on request inputs
|
|
13
13
|
- π― **Type-Safe** - Full TypeScript support with strict typing
|
|
14
14
|
- π **Auto-Routing** - Endpoint folders automatically become API routes
|
|
15
|
+
- π **Plugin System** - Extensible with Supabase and custom plugins
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
|
|
21
|
+
1. [Quick Start](#quick-start)
|
|
22
|
+
2. [Project Structure](#project-structure)
|
|
23
|
+
3. [Creating Endpoints](#creating-endpoints)
|
|
24
|
+
4. [Node Types](#node-types)
|
|
25
|
+
5. [Using Plugins](#using-plugins)
|
|
26
|
+
6. [Configuration](#configuration)
|
|
27
|
+
7. [Commands Reference](#commands-reference)
|
|
28
|
+
8. [Troubleshooting](#troubleshooting)
|
|
29
|
+
9. [Documentation](#documentation)
|
|
15
30
|
|
|
16
31
|
---
|
|
17
32
|
|
|
18
33
|
## Quick Start
|
|
19
|
-
|
|
20
|
-
### 1. Installation
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
### Option 1: Create a New Project (Recommended)
|
|
36
|
+
|
|
37
|
+
The easiest way to start is with the scaffolder:
|
|
23
38
|
|
|
24
39
|
```bash
|
|
25
|
-
|
|
40
|
+
npx create-web-ai-service
|
|
26
41
|
```
|
|
27
42
|
|
|
28
|
-
|
|
43
|
+
You'll be prompted to:
|
|
44
|
+
1. **Enter your project name** - e.g., `my-api`
|
|
45
|
+
2. **Select plugins** - Choose from available plugins like Supabase
|
|
46
|
+
|
|
47
|
+
Or use command-line arguments for non-interactive setup:
|
|
29
48
|
|
|
30
49
|
```bash
|
|
31
|
-
npx web-ai-service
|
|
50
|
+
npx create-web-ai-service my-api --plugins supabase
|
|
32
51
|
```
|
|
33
52
|
|
|
34
|
-
|
|
53
|
+
After scaffolding:
|
|
35
54
|
|
|
36
55
|
```bash
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# Install dependencies
|
|
41
|
-
npm install
|
|
42
|
-
|
|
43
|
-
# Copy environment template
|
|
44
|
-
cp .env.example .env
|
|
56
|
+
cd my-api
|
|
57
|
+
cp .env.example .env # Configure your API keys
|
|
58
|
+
npm run dev # Start the server
|
|
45
59
|
```
|
|
46
60
|
|
|
47
|
-
|
|
61
|
+
Your API is now running at `http://localhost:3000`!
|
|
48
62
|
|
|
49
|
-
|
|
63
|
+
### Option 2: Install as a Dependency
|
|
64
|
+
|
|
65
|
+
Add to an existing project:
|
|
50
66
|
|
|
51
67
|
```bash
|
|
52
|
-
|
|
53
|
-
GEMINI_API_KEY=your-gemini-api-key-here
|
|
54
|
-
GROK_API_KEY=your-grok-api-key-here
|
|
68
|
+
npm install web-ai-service
|
|
55
69
|
```
|
|
56
70
|
|
|
57
|
-
### 3
|
|
71
|
+
### Option 3: Global Installation
|
|
58
72
|
|
|
59
73
|
```bash
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# Production
|
|
64
|
-
npm run build && npm start
|
|
74
|
+
npm install -g web-ai-service
|
|
75
|
+
web-ai-service # Run from any directory with a src/endpoints folder
|
|
65
76
|
```
|
|
66
77
|
|
|
67
|
-
The server starts at `http://localhost:3000`.
|
|
68
|
-
|
|
69
78
|
---
|
|
70
79
|
|
|
71
80
|
## Project Structure
|
|
72
81
|
|
|
82
|
+
When you create a new project, you'll get this structure:
|
|
83
|
+
|
|
73
84
|
```
|
|
74
|
-
|
|
75
|
-
βββ
|
|
76
|
-
β βββ
|
|
77
|
-
β
|
|
78
|
-
β βββ
|
|
79
|
-
β βββ
|
|
80
|
-
β βββ
|
|
81
|
-
β
|
|
82
|
-
|
|
83
|
-
β βββ endpoints/ # Your API endpoints
|
|
84
|
-
β β βββ {endpoint-name}/ # One folder per endpoint route
|
|
85
|
-
β β βββ POST.yaml # Workflow definition (method = filename)
|
|
86
|
-
β β βββ codes/ # Endpoint-specific code files
|
|
87
|
-
β β βββ prompts/ # Endpoint-specific prompt files
|
|
85
|
+
my-api/
|
|
86
|
+
βββ src/
|
|
87
|
+
β βββ endpoints/ # Your API endpoints
|
|
88
|
+
β β βββ hello/ # Example: GET /hello
|
|
89
|
+
β β βββ GET.yaml # Workflow definition
|
|
90
|
+
β β βββ codes/ # TypeScript code nodes
|
|
91
|
+
β β β βββ format-greeting.ts
|
|
92
|
+
β β βββ prompts/ # LLM system prompts
|
|
93
|
+
β β βββ greeting-system.txt
|
|
88
94
|
β β
|
|
89
|
-
β βββ plugins/
|
|
95
|
+
β βββ plugins/ # Shared code modules
|
|
96
|
+
β βββ supabase.ts # (if selected during setup)
|
|
90
97
|
β
|
|
91
|
-
|
|
98
|
+
βββ .env # Your API keys (gitignored)
|
|
99
|
+
βββ .env.example # Template for environment variables
|
|
100
|
+
βββ package.json
|
|
101
|
+
βββ tsconfig.json
|
|
92
102
|
```
|
|
93
103
|
|
|
94
104
|
### Key Concepts
|
|
95
105
|
|
|
96
106
|
| Concept | Description |
|
|
97
107
|
|---------|-------------|
|
|
98
|
-
| **Endpoint** | A folder in `src/endpoints/` that becomes an API route
|
|
99
|
-
| **Workflow** | A YAML file (e.g., `POST.yaml`) defining the
|
|
108
|
+
| **Endpoint** | A folder in `src/endpoints/` that becomes an API route |
|
|
109
|
+
| **Workflow** | A YAML file (e.g., `POST.yaml`, `GET.yaml`) defining the processing pipeline |
|
|
100
110
|
| **Stage** | A sequential step in the workflow containing one or more nodes |
|
|
101
111
|
| **Node** | An individual processing unit (LLM call, code execution, etc.) |
|
|
102
112
|
|
|
103
|
-
|
|
113
|
+
### How Routing Works
|
|
104
114
|
|
|
105
|
-
|
|
115
|
+
| Folder Path | HTTP Method | API Route |
|
|
116
|
+
|-------------|-------------|-----------|
|
|
117
|
+
| `src/endpoints/hello/GET.yaml` | GET | `/hello` |
|
|
118
|
+
| `src/endpoints/summarize/POST.yaml` | POST | `/summarize` |
|
|
119
|
+
| `src/endpoints/users/profile/GET.yaml` | GET | `/users/profile` |
|
|
120
|
+
|
|
121
|
+
---
|
|
106
122
|
|
|
107
|
-
|
|
123
|
+
## Creating Endpoints
|
|
108
124
|
|
|
109
|
-
|
|
125
|
+
### Basic Example: Text Summarization
|
|
110
126
|
|
|
111
|
-
|
|
127
|
+
Create a POST endpoint at `/summarize`:
|
|
112
128
|
|
|
129
|
+
**1. Create the folder structure:**
|
|
113
130
|
```bash
|
|
114
|
-
mkdir -p src/endpoints/summarize/prompts
|
|
131
|
+
mkdir -p src/endpoints/summarize/{codes,prompts}
|
|
115
132
|
```
|
|
116
133
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
Create `src/endpoints/summarize/prompts/summarizer-system.txt`:
|
|
120
|
-
|
|
134
|
+
**2. Create the system prompt** (`src/endpoints/summarize/prompts/system.txt`):
|
|
121
135
|
```text
|
|
122
|
-
You are a concise summarization assistant. Summarize the provided text clearly.
|
|
123
|
-
|
|
124
|
-
Guidelines:
|
|
125
|
-
- Capture the main points and key information
|
|
126
|
-
- Use clear, professional language
|
|
127
|
-
- Keep the summary to 2-3 paragraphs
|
|
136
|
+
You are a concise summarization assistant. Summarize the provided text clearly in 2-3 paragraphs.
|
|
128
137
|
```
|
|
129
138
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
Create `src/endpoints/summarize/POST.yaml`:
|
|
133
|
-
|
|
139
|
+
**3. Create the workflow** (`src/endpoints/summarize/POST.yaml`):
|
|
134
140
|
```yaml
|
|
135
141
|
version: "1.0"
|
|
136
142
|
|
|
@@ -139,148 +145,350 @@ stages:
|
|
|
139
145
|
nodes:
|
|
140
146
|
summarize:
|
|
141
147
|
type: llm
|
|
142
|
-
input: $input
|
|
148
|
+
input: $input.text
|
|
143
149
|
provider: gemini
|
|
144
150
|
model: gemini-2.0-flash-lite
|
|
145
151
|
temperature: 0.3
|
|
146
152
|
maxTokens: 1024
|
|
147
153
|
systemMessages:
|
|
148
|
-
- file:
|
|
149
|
-
cache: true
|
|
154
|
+
- file: system.txt
|
|
150
155
|
```
|
|
151
156
|
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
**4. Test it:**
|
|
154
158
|
```bash
|
|
155
|
-
npm run dev
|
|
156
|
-
|
|
157
159
|
curl -X POST http://localhost:3000/summarize \
|
|
158
160
|
-H "Content-Type: application/json" \
|
|
159
|
-
-d '{"text": "
|
|
161
|
+
-d '{"text": "Long text to summarize..."}'
|
|
160
162
|
```
|
|
161
163
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
## Adding Custom Code Nodes
|
|
165
|
-
|
|
166
|
-
For custom processing logic, add TypeScript files to your endpoint's `codes/` folder.
|
|
167
|
-
|
|
168
|
-
### Example: Validation + Processing
|
|
164
|
+
### Adding Input Validation with Code Nodes
|
|
169
165
|
|
|
170
|
-
Create
|
|
166
|
+
Create a code node to validate inputs before processing:
|
|
171
167
|
|
|
168
|
+
**`src/endpoints/summarize/codes/validate.ts`:**
|
|
172
169
|
```typescript
|
|
173
170
|
import type { NodeOutput } from '@workflow/types';
|
|
174
171
|
|
|
172
|
+
interface SummarizeInput {
|
|
173
|
+
text?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
175
176
|
export default async function(input: unknown): Promise<NodeOutput> {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
const body = input as SummarizeInput;
|
|
178
|
+
|
|
179
|
+
if (!body.text || typeof body.text !== 'string') {
|
|
180
|
+
throw new Error('Missing required field: text');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (body.text.length < 10) {
|
|
184
|
+
throw new Error('Text must be at least 10 characters');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return { type: 'string', value: body.text };
|
|
187
188
|
}
|
|
188
189
|
```
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
**Updated workflow with validation stage:**
|
|
192
|
+
```yaml
|
|
193
|
+
version: "1.0"
|
|
194
|
+
|
|
195
|
+
stages:
|
|
196
|
+
- name: validate
|
|
197
|
+
nodes:
|
|
198
|
+
check_input:
|
|
199
|
+
type: code
|
|
200
|
+
input: $input
|
|
201
|
+
file: validate.ts
|
|
202
|
+
|
|
203
|
+
- name: summarize
|
|
204
|
+
nodes:
|
|
205
|
+
summary:
|
|
206
|
+
type: llm
|
|
207
|
+
input: validate.check_input # Reference previous node output
|
|
208
|
+
provider: gemini
|
|
209
|
+
model: gemini-2.0-flash-lite
|
|
210
|
+
systemMessages:
|
|
211
|
+
- file: system.txt
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Multi-Stage Workflow Example
|
|
215
|
+
|
|
216
|
+
Chain multiple processing stages:
|
|
191
217
|
|
|
192
218
|
```yaml
|
|
193
219
|
version: "1.0"
|
|
194
220
|
|
|
195
221
|
stages:
|
|
196
|
-
- name:
|
|
222
|
+
- name: extract
|
|
197
223
|
nodes:
|
|
198
|
-
|
|
224
|
+
parse_data:
|
|
199
225
|
type: code
|
|
200
226
|
input: $input
|
|
201
|
-
file:
|
|
227
|
+
file: extract-data.ts
|
|
202
228
|
|
|
203
|
-
- name:
|
|
229
|
+
- name: analyze
|
|
204
230
|
nodes:
|
|
205
|
-
|
|
231
|
+
analyze_content:
|
|
206
232
|
type: llm
|
|
207
|
-
input:
|
|
233
|
+
input: extract.parse_data
|
|
208
234
|
provider: gemini
|
|
209
235
|
model: gemini-2.0-flash-lite
|
|
210
|
-
temperature: 0.3
|
|
211
|
-
maxTokens: 1024
|
|
212
236
|
systemMessages:
|
|
213
|
-
- file:
|
|
214
|
-
|
|
237
|
+
- file: analyzer-prompt.txt
|
|
238
|
+
|
|
239
|
+
- name: format
|
|
240
|
+
nodes:
|
|
241
|
+
format_response:
|
|
242
|
+
type: code
|
|
243
|
+
input: analyze.analyze_content
|
|
244
|
+
file: format-output.ts
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Parallel Node Execution
|
|
248
|
+
|
|
249
|
+
Run multiple LLM calls simultaneously within a stage:
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
stages:
|
|
253
|
+
- name: parallel_analysis
|
|
254
|
+
nodes:
|
|
255
|
+
sentiment:
|
|
256
|
+
type: llm
|
|
257
|
+
input: $input.text
|
|
258
|
+
provider: gemini
|
|
259
|
+
model: gemini-2.0-flash-lite
|
|
260
|
+
systemMessages:
|
|
261
|
+
- file: sentiment-prompt.txt
|
|
262
|
+
|
|
263
|
+
keywords:
|
|
264
|
+
type: llm
|
|
265
|
+
input: $input.text
|
|
266
|
+
provider: openai
|
|
267
|
+
model: gpt-4o-mini
|
|
268
|
+
systemMessages:
|
|
269
|
+
- file: keywords-prompt.txt
|
|
270
|
+
|
|
271
|
+
- name: combine
|
|
272
|
+
nodes:
|
|
273
|
+
merge:
|
|
274
|
+
type: reduce
|
|
275
|
+
inputs:
|
|
276
|
+
- parallel_analysis.sentiment
|
|
277
|
+
- parallel_analysis.keywords
|
|
278
|
+
mapping:
|
|
279
|
+
sentiment: $.0
|
|
280
|
+
keywords: $.1
|
|
215
281
|
```
|
|
216
282
|
|
|
217
283
|
---
|
|
218
284
|
|
|
219
|
-
##
|
|
285
|
+
## Node Types
|
|
220
286
|
|
|
221
|
-
|
|
287
|
+
### LLM Node
|
|
288
|
+
|
|
289
|
+
Call an LLM provider:
|
|
290
|
+
|
|
291
|
+
```yaml
|
|
292
|
+
my_llm_node:
|
|
293
|
+
type: llm
|
|
294
|
+
input: $input.text # or reference: stageName.nodeName
|
|
295
|
+
provider: gemini # gemini | openai | anthropic | grok
|
|
296
|
+
model: gemini-2.0-flash-lite
|
|
297
|
+
temperature: 0.7 # Optional (0.0-1.0)
|
|
298
|
+
maxTokens: 1024 # Optional
|
|
299
|
+
systemMessages:
|
|
300
|
+
- file: prompt.txt
|
|
301
|
+
cache: true # Cache for performance
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Supported Providers & Models:**
|
|
305
|
+
|
|
306
|
+
| Provider | Example Models |
|
|
307
|
+
|----------|----------------|
|
|
308
|
+
| `gemini` | `gemini-2.0-flash-lite`, `gemini-2.0-flash`, `gemini-1.5-pro` |
|
|
309
|
+
| `openai` | `gpt-4o`, `gpt-4o-mini`, `gpt-4-turbo` |
|
|
310
|
+
| `anthropic` | `claude-3-5-sonnet-latest`, `claude-3-haiku-20240307` |
|
|
311
|
+
| `grok` | `grok-2`, `grok-2-mini` |
|
|
312
|
+
|
|
313
|
+
### Code Node
|
|
314
|
+
|
|
315
|
+
Execute custom TypeScript:
|
|
316
|
+
|
|
317
|
+
```yaml
|
|
318
|
+
my_code_node:
|
|
319
|
+
type: code
|
|
320
|
+
input: $input
|
|
321
|
+
file: my-processor.ts
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The TypeScript file must export a default async function:
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import type { NodeOutput } from '@workflow/types';
|
|
328
|
+
|
|
329
|
+
export default async function(input: unknown): Promise<NodeOutput> {
|
|
330
|
+
// Your logic here
|
|
331
|
+
return {
|
|
332
|
+
type: 'json', // 'string' | 'json' | 'number' | 'boolean' | 'array'
|
|
333
|
+
value: { processed: true }
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Reduce Node
|
|
339
|
+
|
|
340
|
+
Combine multiple node outputs:
|
|
341
|
+
|
|
342
|
+
```yaml
|
|
343
|
+
merge_results:
|
|
344
|
+
type: reduce
|
|
345
|
+
inputs:
|
|
346
|
+
- stageName.node1
|
|
347
|
+
- stageName.node2
|
|
348
|
+
mapping:
|
|
349
|
+
firstResult: $.0
|
|
350
|
+
secondResult: $.1
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Split Node
|
|
354
|
+
|
|
355
|
+
Divide output into named parts:
|
|
356
|
+
|
|
357
|
+
```yaml
|
|
358
|
+
split_data:
|
|
359
|
+
type: split
|
|
360
|
+
input: stageName.nodeName
|
|
361
|
+
mapping:
|
|
362
|
+
header: $.header
|
|
363
|
+
body: $.content
|
|
364
|
+
footer: $.footer
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Passthrough Node
|
|
368
|
+
|
|
369
|
+
Pass input directly to output:
|
|
370
|
+
|
|
371
|
+
```yaml
|
|
372
|
+
forward:
|
|
373
|
+
type: passthrough
|
|
374
|
+
input: $input
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Using Plugins
|
|
380
|
+
|
|
381
|
+
### Supabase Plugin
|
|
382
|
+
|
|
383
|
+
If you selected Supabase during project setup, you can use it in code nodes:
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { supabase } from '@code-plugins/supabase.js';
|
|
387
|
+
import type { NodeOutput } from '@workflow/types';
|
|
388
|
+
|
|
389
|
+
export default async function(input: unknown): Promise<NodeOutput> {
|
|
390
|
+
const { data, error } = await supabase
|
|
391
|
+
.from('articles')
|
|
392
|
+
.select('*')
|
|
393
|
+
.limit(10);
|
|
394
|
+
|
|
395
|
+
if (error) {
|
|
396
|
+
throw new Error(`Database error: ${error.message}`);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return { type: 'json', value: data };
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Configure in `.env`:
|
|
404
|
+
```bash
|
|
405
|
+
SUPABASE_URL=https://your-project.supabase.co
|
|
406
|
+
SUPABASE_ANON_KEY=your-anon-key
|
|
407
|
+
SUPABASE_SERVICE_KEY=your-service-key # Optional
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Creating Custom Plugins
|
|
411
|
+
|
|
412
|
+
Add files to `src/plugins/` and import via `@code-plugins/*`:
|
|
222
413
|
|
|
223
414
|
```typescript
|
|
224
|
-
//
|
|
225
|
-
|
|
415
|
+
// src/plugins/my-helper.ts
|
|
416
|
+
export function formatDate(date: Date): string {
|
|
417
|
+
return date.toISOString().split('T')[0];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// In any code node:
|
|
421
|
+
import { formatDate } from '@code-plugins/my-helper.js';
|
|
226
422
|
```
|
|
227
423
|
|
|
228
424
|
---
|
|
229
425
|
|
|
230
|
-
##
|
|
426
|
+
## Configuration
|
|
231
427
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
|
235
|
-
|
|
236
|
-
| `
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
428
|
+
### Environment Variables
|
|
429
|
+
|
|
430
|
+
| Variable | Default | Description |
|
|
431
|
+
|----------|---------|-------------|
|
|
432
|
+
| `PORT` | `3000` | Server port |
|
|
433
|
+
| `LOG_LEVEL` | `info` | Logging level (`debug`, `info`, `warn`, `error`) |
|
|
434
|
+
| `LLM_TIMEOUT_MS` | `30000` | LLM request timeout |
|
|
435
|
+
|
|
436
|
+
### LLM Provider API Keys
|
|
437
|
+
|
|
438
|
+
You need at least one provider configured:
|
|
439
|
+
|
|
440
|
+
| Variable | Provider |
|
|
441
|
+
|----------|----------|
|
|
442
|
+
| `GEMINI_API_KEY` | Google Gemini |
|
|
443
|
+
| `OPENAI_API_KEY` | OpenAI |
|
|
444
|
+
| `ANTHROPIC_API_KEY` | Anthropic Claude |
|
|
445
|
+
| `GROK_API_KEY` | xAI Grok |
|
|
446
|
+
|
|
447
|
+
### Plugin-Specific Variables
|
|
448
|
+
|
|
449
|
+
| Variable | Plugin |
|
|
450
|
+
|----------|--------|
|
|
451
|
+
| `SUPABASE_URL` | Supabase |
|
|
452
|
+
| `SUPABASE_ANON_KEY` | Supabase |
|
|
453
|
+
| `SUPABASE_SERVICE_KEY` | Supabase (optional) |
|
|
239
454
|
|
|
240
455
|
---
|
|
241
456
|
|
|
242
|
-
##
|
|
457
|
+
## Commands Reference
|
|
243
458
|
|
|
244
459
|
| Command | Description |
|
|
245
460
|
|---------|-------------|
|
|
246
461
|
| `npm run dev` | Start development server with hot reload |
|
|
247
|
-
| `npm run create-endpoint` | Scaffold a new API endpoint interactively |
|
|
248
462
|
| `npm run build` | Compile TypeScript to JavaScript |
|
|
249
463
|
| `npm start` | Start production server |
|
|
250
464
|
| `npm run validate` | Validate all workflows |
|
|
465
|
+
| `npm run create-endpoint` | Scaffold a new endpoint interactively |
|
|
251
466
|
| `npm run scan-deps` | Scan and install code node dependencies |
|
|
252
467
|
| `npm run lint` | Run ESLint |
|
|
253
468
|
| `npm run format` | Format code with Prettier |
|
|
254
469
|
|
|
255
470
|
---
|
|
256
471
|
|
|
257
|
-
## Environment Variables
|
|
258
|
-
|
|
259
|
-
| Variable | Default | Description |
|
|
260
|
-
|----------|---------|-------------|
|
|
261
|
-
| `PORT` | `3000` | Server port |
|
|
262
|
-
| `GEMINI_API_KEY` | - | Gemini API key (required for Gemini) |
|
|
263
|
-
| `GROK_API_KEY` | - | Grok API key (required for Grok) |
|
|
264
|
-
| `LLM_TIMEOUT_MS` | `30000` | LLM call timeout |
|
|
265
|
-
| `LOG_LEVEL` | `info` | Logging level (`debug`, `info`, `warn`, `error`) |
|
|
266
|
-
|
|
267
|
-
---
|
|
268
|
-
|
|
269
472
|
## Troubleshooting
|
|
270
473
|
|
|
271
474
|
| Error | Solution |
|
|
272
475
|
|-------|----------|
|
|
273
|
-
| "Provider not found" | Check `provider` is
|
|
476
|
+
| "Provider not found" | Check `provider` is valid and API key is set in `.env` |
|
|
274
477
|
| "Code node file not found" | Verify file exists in `codes/` folder with correct filename |
|
|
275
478
|
| "Cannot find module '@workflow/types'" | Run `npm run build` or restart TypeScript server |
|
|
276
479
|
| LLM Timeout | Increase `LLM_TIMEOUT_MS` in `.env` or use a faster model |
|
|
480
|
+
| "SUPABASE_URL required" | Add Supabase credentials to `.env` |
|
|
277
481
|
|
|
278
482
|
---
|
|
279
483
|
|
|
280
484
|
## Documentation
|
|
281
485
|
|
|
282
|
-
|
|
283
|
-
|
|
486
|
+
For more detailed guides, see the `docs/` folder:
|
|
487
|
+
|
|
488
|
+
- [Getting Started](docs/getting-started.md) - Complete setup walkthrough
|
|
489
|
+
- [Creating Endpoints](docs/creating-endpoints.md) - Advanced endpoint patterns
|
|
490
|
+
- [Using Plugins](docs/using-plugins.md) - Plugin configuration and custom plugins
|
|
491
|
+
- [Configuration Reference](docs/configuration.md) - All environment options
|
|
284
492
|
|
|
285
493
|
## License
|
|
286
494
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-costs.d.ts","sourceRoot":"","sources":["../../../engine/config/llm-costs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,SAAS;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"llm-costs.d.ts","sourceRoot":"","sources":["../../../engine/config/llm-costs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,SAAS;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAiCrD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAerD"}
|
|
@@ -16,6 +16,20 @@ export const defaultLLMCosts = {
|
|
|
16
16
|
// Grok Models
|
|
17
17
|
'grok-4-1-fast-reasoning': { inputCostPer1M: 0.20, cachedInputCostPer1M: 0.20, outputCostPer1M: 0.50 },
|
|
18
18
|
'grok-4-1-fast-non-reasoning': { inputCostPer1M: 0.20, cachedInputCostPer1M: 0.20, outputCostPer1M: 0.50 },
|
|
19
|
+
// OpenAI Models
|
|
20
|
+
'gpt-4o': { inputCostPer1M: 2.50, cachedInputCostPer1M: 1.25, outputCostPer1M: 10.00 },
|
|
21
|
+
'gpt-4o-mini': { inputCostPer1M: 0.15, cachedInputCostPer1M: 0.075, outputCostPer1M: 0.60 },
|
|
22
|
+
'gpt-4-turbo': { inputCostPer1M: 10.00, outputCostPer1M: 30.00 },
|
|
23
|
+
'gpt-4': { inputCostPer1M: 30.00, outputCostPer1M: 60.00 },
|
|
24
|
+
'gpt-3.5-turbo': { inputCostPer1M: 0.50, outputCostPer1M: 1.50 },
|
|
25
|
+
'o1': { inputCostPer1M: 15.00, cachedInputCostPer1M: 7.50, outputCostPer1M: 60.00 },
|
|
26
|
+
'o1-mini': { inputCostPer1M: 3.00, cachedInputCostPer1M: 1.50, outputCostPer1M: 12.00 },
|
|
27
|
+
'o3-mini': { inputCostPer1M: 1.10, cachedInputCostPer1M: 0.55, outputCostPer1M: 4.40 },
|
|
28
|
+
// Anthropic Models
|
|
29
|
+
'claude-sonnet-4-20250514': { inputCostPer1M: 3.00, cachedInputCostPer1M: 0.30, outputCostPer1M: 15.00 },
|
|
30
|
+
'claude-3-5-sonnet-20241022': { inputCostPer1M: 3.00, cachedInputCostPer1M: 0.30, outputCostPer1M: 15.00 },
|
|
31
|
+
'claude-3-5-haiku-20241022': { inputCostPer1M: 0.80, cachedInputCostPer1M: 0.08, outputCostPer1M: 4.00 },
|
|
32
|
+
'claude-3-opus-20240229': { inputCostPer1M: 15.00, cachedInputCostPer1M: 1.50, outputCostPer1M: 75.00 },
|
|
19
33
|
};
|
|
20
34
|
/**
|
|
21
35
|
* Get cost for a specific model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-costs.js","sourceRoot":"","sources":["../../../engine/config/llm-costs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,CAAC,MAAM,eAAe,GAA8B;IACtD,0BAA0B;IAC1B,sBAAsB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE;IACpG,wBAAwB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE;IA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ine/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../engine/index.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,wBAAsB,IAAI,kBAiEzB"}
|
package/dist/engine/index.js
CHANGED
|
@@ -6,6 +6,8 @@ import { validateWorkflow } from './core/validator.js';
|
|
|
6
6
|
import { providerRegistry } from './providers/registry.js';
|
|
7
7
|
import { GeminiProvider } from './providers/gemini.js';
|
|
8
8
|
import { GrokProvider } from './providers/grok.js';
|
|
9
|
+
import { OpenAIProvider } from './providers/openai.js';
|
|
10
|
+
import { AnthropicProvider } from './providers/anthropic.js';
|
|
9
11
|
import logger from './utils/logger.js';
|
|
10
12
|
// Load environment variables
|
|
11
13
|
dotenv.config();
|
|
@@ -19,6 +21,8 @@ export async function main() {
|
|
|
19
21
|
logger.info('Registering LLM providers...');
|
|
20
22
|
providerRegistry.register(new GeminiProvider());
|
|
21
23
|
providerRegistry.register(new GrokProvider());
|
|
24
|
+
providerRegistry.register(new OpenAIProvider());
|
|
25
|
+
providerRegistry.register(new AnthropicProvider());
|
|
22
26
|
// Load workflows
|
|
23
27
|
logger.info('Loading workflows...');
|
|
24
28
|
const workflows = await loadAllWorkflows();
|
package/dist/engine/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBA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ementation
|
|
4
|
+
*/
|
|
5
|
+
export declare class AnthropicProvider implements LLMProvider {
|
|
6
|
+
name: string;
|
|
7
|
+
private client;
|
|
8
|
+
private apiKey;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Validate Anthropic configuration
|
|
12
|
+
*/
|
|
13
|
+
validateConfig(config: LLMConfig): Promise<ValidationResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Call Anthropic API
|
|
16
|
+
*/
|
|
17
|
+
call(params: LLMCallParams): Promise<LLMResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a feature is supported
|
|
20
|
+
*/
|
|
21
|
+
supportsFeature(feature: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Build custom config parameters
|
|
24
|
+
*/
|
|
25
|
+
private buildCustomConfig;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../engine/providers/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,gBAAgB,EACnB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IACjD,IAAI,SAAe;IACnB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,MAAM,CAAqB;;IAYnC;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsClE;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IAuEvD;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAKzC;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAgB5B"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import logger from '../utils/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* Anthropic LLM provider implementation
|
|
5
|
+
*/
|
|
6
|
+
export class AnthropicProvider {
|
|
7
|
+
name = 'anthropic';
|
|
8
|
+
client = null;
|
|
9
|
+
apiKey;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.apiKey = process.env.ANTHROPIC_API_KEY;
|
|
12
|
+
if (this.apiKey) {
|
|
13
|
+
this.client = new Anthropic({ apiKey: this.apiKey });
|
|
14
|
+
logger.info('Anthropic provider initialized');
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
logger.warn('Anthropic API key not found, provider will not be functional');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Validate Anthropic configuration
|
|
22
|
+
*/
|
|
23
|
+
async validateConfig(config) {
|
|
24
|
+
const errors = [];
|
|
25
|
+
if (!config.model) {
|
|
26
|
+
errors.push({
|
|
27
|
+
code: 'MISSING_MODEL',
|
|
28
|
+
message: 'Model is required for Anthropic provider',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (!this.apiKey) {
|
|
32
|
+
errors.push({
|
|
33
|
+
code: 'MISSING_API_KEY',
|
|
34
|
+
message: 'ANTHROPIC_API_KEY environment variable is not set',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (config.temperature !== undefined && (config.temperature < 0 || config.temperature > 1)) {
|
|
38
|
+
errors.push({
|
|
39
|
+
code: 'INVALID_TEMPERATURE',
|
|
40
|
+
message: 'Temperature must be between 0 and 1 for Anthropic',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (config.maxTokens !== undefined && config.maxTokens < 1) {
|
|
44
|
+
errors.push({
|
|
45
|
+
code: 'INVALID_MAX_TOKENS',
|
|
46
|
+
message: 'Max tokens must be a positive number',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (errors.length > 0) {
|
|
50
|
+
return { valid: false, errors };
|
|
51
|
+
}
|
|
52
|
+
return { valid: true };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Call Anthropic API
|
|
56
|
+
*/
|
|
57
|
+
async call(params) {
|
|
58
|
+
if (!this.client) {
|
|
59
|
+
throw new Error('Anthropic client not initialized. Check ANTHROPIC_API_KEY.');
|
|
60
|
+
}
|
|
61
|
+
const { config, systemMessages, userMessage } = params;
|
|
62
|
+
const timeout = parseInt(process.env.LLM_TIMEOUT_MS || '30000', 10);
|
|
63
|
+
try {
|
|
64
|
+
// Build system message
|
|
65
|
+
const system = systemMessages.length > 0
|
|
66
|
+
? systemMessages.map((msg) => msg.content).join('\n\n')
|
|
67
|
+
: undefined;
|
|
68
|
+
// Call with timeout
|
|
69
|
+
const message = await Promise.race([
|
|
70
|
+
this.client.messages.create({
|
|
71
|
+
model: config.model,
|
|
72
|
+
max_tokens: config.maxTokens || 4096,
|
|
73
|
+
system,
|
|
74
|
+
messages: [
|
|
75
|
+
{
|
|
76
|
+
role: 'user',
|
|
77
|
+
content: userMessage,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
temperature: config.temperature,
|
|
81
|
+
...this.buildCustomConfig(config),
|
|
82
|
+
}),
|
|
83
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('LLM_TIMEOUT')), timeout)),
|
|
84
|
+
]);
|
|
85
|
+
// Extract text from content blocks
|
|
86
|
+
const text = message.content
|
|
87
|
+
.filter((block) => block.type === 'text')
|
|
88
|
+
.map((block) => block.text)
|
|
89
|
+
.join('');
|
|
90
|
+
// Extract usage
|
|
91
|
+
const usage = message.usage
|
|
92
|
+
? {
|
|
93
|
+
inputTokens: message.usage.input_tokens || 0,
|
|
94
|
+
outputTokens: message.usage.output_tokens || 0,
|
|
95
|
+
}
|
|
96
|
+
: undefined;
|
|
97
|
+
logger.debug('Anthropic API call successful', {
|
|
98
|
+
model: config.model,
|
|
99
|
+
inputTokens: usage?.inputTokens,
|
|
100
|
+
outputTokens: usage?.outputTokens,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
content: text,
|
|
104
|
+
usage,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
if (message === 'LLM_TIMEOUT') {
|
|
110
|
+
logger.error('Anthropic API timeout', { timeout, model: config.model });
|
|
111
|
+
throw new Error(`LLM_TIMEOUT: Request timed out after ${timeout}ms`);
|
|
112
|
+
}
|
|
113
|
+
logger.error('Anthropic API error', { error: message, model: config.model });
|
|
114
|
+
throw new Error(`LLM_API_ERROR: ${message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check if a feature is supported
|
|
119
|
+
*/
|
|
120
|
+
supportsFeature(feature) {
|
|
121
|
+
const supportedFeatures = ['systemMessages', 'temperature', 'maxTokens'];
|
|
122
|
+
return supportedFeatures.includes(feature);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build custom config parameters
|
|
126
|
+
*/
|
|
127
|
+
buildCustomConfig(config) {
|
|
128
|
+
const customConfig = {};
|
|
129
|
+
if (config.custom) {
|
|
130
|
+
const supported = ['top_p', 'top_k', 'stop_sequences'];
|
|
131
|
+
for (const [key, value] of Object.entries(config.custom)) {
|
|
132
|
+
if (supported.includes(key)) {
|
|
133
|
+
customConfig[key] = value;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
logger.warn(`Unsupported custom config key for Anthropic: ${key}`, { key, value });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return customConfig;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../engine/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;A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
|
|
1
|
+
import type { LLMProvider, LLMConfig, LLMCallParams, LLMResponse, ValidationResult } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* OpenAI LLM provider implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare class OpenAIProvider implements LLMProvider {
|
|
6
|
+
name: string;
|
|
7
|
+
private client;
|
|
8
|
+
private apiKey;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Validate OpenAI configuration
|
|
12
|
+
*/
|
|
13
|
+
validateConfig(config: LLMConfig): Promise<ValidationResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Call OpenAI API
|
|
16
|
+
*/
|
|
17
|
+
call(params: LLMCallParams): Promise<LLMResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a feature is supported
|
|
20
|
+
*/
|
|
21
|
+
supportsFeature(feature: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Build custom config parameters
|
|
24
|
+
*/
|
|
25
|
+
private buildCustomConfig;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../engine/providers/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,gBAAgB,EACnB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAC9C,IAAI,SAAY;IAChB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAqB;;IAYnC;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsClE;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IAyEvD;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAKzC;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAgB5B"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import logger from '../utils/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* OpenAI LLM provider implementation
|
|
5
|
+
*/
|
|
6
|
+
export class OpenAIProvider {
|
|
7
|
+
name = 'openai';
|
|
8
|
+
client = null;
|
|
9
|
+
apiKey;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.apiKey = process.env.OPENAI_API_KEY;
|
|
12
|
+
if (this.apiKey) {
|
|
13
|
+
this.client = new OpenAI({ apiKey: this.apiKey });
|
|
14
|
+
logger.info('OpenAI provider initialized');
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
logger.warn('OpenAI API key not found, provider will not be functional');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Validate OpenAI configuration
|
|
22
|
+
*/
|
|
23
|
+
async validateConfig(config) {
|
|
24
|
+
const errors = [];
|
|
25
|
+
if (!config.model) {
|
|
26
|
+
errors.push({
|
|
27
|
+
code: 'MISSING_MODEL',
|
|
28
|
+
message: 'Model is required for OpenAI provider',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (!this.apiKey) {
|
|
32
|
+
errors.push({
|
|
33
|
+
code: 'MISSING_API_KEY',
|
|
34
|
+
message: 'OPENAI_API_KEY environment variable is not set',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (config.temperature !== undefined && (config.temperature < 0 || config.temperature > 2)) {
|
|
38
|
+
errors.push({
|
|
39
|
+
code: 'INVALID_TEMPERATURE',
|
|
40
|
+
message: 'Temperature must be between 0 and 2',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (config.maxTokens !== undefined && config.maxTokens < 1) {
|
|
44
|
+
errors.push({
|
|
45
|
+
code: 'INVALID_MAX_TOKENS',
|
|
46
|
+
message: 'Max tokens must be a positive number',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (errors.length > 0) {
|
|
50
|
+
return { valid: false, errors };
|
|
51
|
+
}
|
|
52
|
+
return { valid: true };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Call OpenAI API
|
|
56
|
+
*/
|
|
57
|
+
async call(params) {
|
|
58
|
+
if (!this.client) {
|
|
59
|
+
throw new Error('OpenAI client not initialized. Check OPENAI_API_KEY.');
|
|
60
|
+
}
|
|
61
|
+
const { config, systemMessages, userMessage } = params;
|
|
62
|
+
const timeout = parseInt(process.env.LLM_TIMEOUT_MS || '30000', 10);
|
|
63
|
+
try {
|
|
64
|
+
// Build messages array
|
|
65
|
+
const messages = [];
|
|
66
|
+
// Add system messages
|
|
67
|
+
if (systemMessages.length > 0) {
|
|
68
|
+
messages.push({
|
|
69
|
+
role: 'system',
|
|
70
|
+
content: systemMessages.map((msg) => msg.content).join('\n\n'),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Add user message
|
|
74
|
+
messages.push({
|
|
75
|
+
role: 'user',
|
|
76
|
+
content: userMessage,
|
|
77
|
+
});
|
|
78
|
+
// Call with timeout
|
|
79
|
+
const completion = await Promise.race([
|
|
80
|
+
this.client.chat.completions.create({
|
|
81
|
+
model: config.model,
|
|
82
|
+
messages,
|
|
83
|
+
temperature: config.temperature,
|
|
84
|
+
max_tokens: config.maxTokens,
|
|
85
|
+
...this.buildCustomConfig(config),
|
|
86
|
+
}),
|
|
87
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('LLM_TIMEOUT')), timeout)),
|
|
88
|
+
]);
|
|
89
|
+
const text = completion.choices[0]?.message?.content || '';
|
|
90
|
+
// Extract usage
|
|
91
|
+
const usage = completion.usage
|
|
92
|
+
? {
|
|
93
|
+
inputTokens: completion.usage.prompt_tokens || 0,
|
|
94
|
+
outputTokens: completion.usage.completion_tokens || 0,
|
|
95
|
+
}
|
|
96
|
+
: undefined;
|
|
97
|
+
logger.debug('OpenAI API call successful', {
|
|
98
|
+
model: config.model,
|
|
99
|
+
inputTokens: usage?.inputTokens,
|
|
100
|
+
outputTokens: usage?.outputTokens,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
content: text,
|
|
104
|
+
usage,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
if (message === 'LLM_TIMEOUT') {
|
|
110
|
+
logger.error('OpenAI API timeout', { timeout, model: config.model });
|
|
111
|
+
throw new Error(`LLM_TIMEOUT: Request timed out after ${timeout}ms`);
|
|
112
|
+
}
|
|
113
|
+
logger.error('OpenAI API error', { error: message, model: config.model });
|
|
114
|
+
throw new Error(`LLM_API_ERROR: ${message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check if a feature is supported
|
|
119
|
+
*/
|
|
120
|
+
supportsFeature(feature) {
|
|
121
|
+
const supportedFeatures = ['systemMessages', 'temperature', 'maxTokens', 'streaming'];
|
|
122
|
+
return supportedFeatures.includes(feature);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build custom config parameters
|
|
126
|
+
*/
|
|
127
|
+
buildCustomConfig(config) {
|
|
128
|
+
const customConfig = {};
|
|
129
|
+
if (config.custom) {
|
|
130
|
+
const supported = ['top_p', 'frequency_penalty', 'presence_penalty', 'stop'];
|
|
131
|
+
for (const [key, value] of Object.entries(config.custom)) {
|
|
132
|
+
if (supported.includes(key)) {
|
|
133
|
+
customConfig[key] = value;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
logger.warn(`Unsupported custom config key for OpenAI: ${key}`, { key, value });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return customConfig;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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BACpF,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ"}
|
|
@@ -39,7 +39,7 @@ export interface BaseNodeDefinition {
|
|
|
39
39
|
export interface LLMNodeDefinition extends BaseNodeDefinition {
|
|
40
40
|
type: 'llm';
|
|
41
41
|
llmRef?: string;
|
|
42
|
-
provider?: 'gemini' | 'grok';
|
|
42
|
+
provider?: 'gemini' | 'grok' | 'openai' | 'anthropic';
|
|
43
43
|
config?: LLMConfig;
|
|
44
44
|
systemMessages?: SystemMessage[];
|
|
45
45
|
input: string;
|
|
@@ -105,7 +105,7 @@ export type InlineNodeDefinition = InlineLLMNode | InlineCodeNode | InlineReduce
|
|
|
105
105
|
export interface InlineLLMNode {
|
|
106
106
|
type: 'llm';
|
|
107
107
|
input: string;
|
|
108
|
-
provider?: 'gemini' | 'grok';
|
|
108
|
+
provider?: 'gemini' | 'grok' | 'openai' | 'anthropic';
|
|
109
109
|
model?: string;
|
|
110
110
|
temperature?: number;
|
|
111
111
|
maxTokens?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../engine/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;IACzD,KAAK,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,IAAI,CAAC,EAAE,MAAM,CA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AC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACnD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,oBAAY,SAAS;IACjB,iBAAiB,sBAAsB;IACvC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CACpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-ai-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "TypeScript-based Web AI Service that creates configurable AI-powered endpoints from YAML definitions",
|
|
5
5
|
"main": "dist/engine/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,12 +31,15 @@
|
|
|
31
31
|
"author": "",
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@anthropic-ai/sdk": "^0.71.2",
|
|
34
35
|
"@google/generative-ai": "^0.21.0",
|
|
36
|
+
"@supabase/supabase-js": "^2.90.1",
|
|
35
37
|
"@xmldom/xmldom": "^0.8.11",
|
|
36
38
|
"ajv": "^8.12.0",
|
|
37
39
|
"dotenv": "^16.4.1",
|
|
38
40
|
"express": "^4.18.2",
|
|
39
41
|
"jsonpath-plus": "^10.2.0",
|
|
42
|
+
"openai": "^6.16.0",
|
|
40
43
|
"winston": "^3.11.0",
|
|
41
44
|
"yaml": "^2.3.4"
|
|
42
45
|
},
|