aparavi-client 1.0.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/LICENSE +21 -0
- package/README.md +523 -0
- package/dist/aparavi-client-typescript-1.0.0.tgz +0 -0
- package/dist/aparavi-client-typescript-1.0.1.tgz +0 -0
- package/dist/cjs/client.js +1002 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/constants.js +37 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/core/DAPBase.js +313 -0
- package/dist/cjs/core/DAPBase.js.map +1 -0
- package/dist/cjs/core/DAPClient.js +173 -0
- package/dist/cjs/core/DAPClient.js.map +1 -0
- package/dist/cjs/core/TransportBase.js +131 -0
- package/dist/cjs/core/TransportBase.js.map +1 -0
- package/dist/cjs/core/TransportWebSocket.js +492 -0
- package/dist/cjs/core/TransportWebSocket.js.map +1 -0
- package/dist/cjs/exceptions/index.js +109 -0
- package/dist/cjs/exceptions/index.js.map +1 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/schema/Doc.js +79 -0
- package/dist/cjs/schema/Doc.js.map +1 -0
- package/dist/cjs/schema/DocFilter.js +133 -0
- package/dist/cjs/schema/DocFilter.js.map +1 -0
- package/dist/cjs/schema/DocGroup.js +235 -0
- package/dist/cjs/schema/DocGroup.js.map +1 -0
- package/dist/cjs/schema/DocMetadata.js +57 -0
- package/dist/cjs/schema/DocMetadata.js.map +1 -0
- package/dist/cjs/schema/Question.js +414 -0
- package/dist/cjs/schema/Question.js.map +1 -0
- package/dist/cjs/schema/index.js +50 -0
- package/dist/cjs/schema/index.js.map +1 -0
- package/dist/cjs/types/client.js +26 -0
- package/dist/cjs/types/client.js.map +1 -0
- package/dist/cjs/types/data.js +26 -0
- package/dist/cjs/types/data.js.map +1 -0
- package/dist/cjs/types/events.js +119 -0
- package/dist/cjs/types/events.js.map +1 -0
- package/dist/cjs/types/index.js +50 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/pipeline.js +26 -0
- package/dist/cjs/types/pipeline.js.map +1 -0
- package/dist/cjs/types/task.js +115 -0
- package/dist/cjs/types/task.js.map +1 -0
- package/dist/cli/cli/aparavi.js +1401 -0
- package/dist/cli/cli/aparavi.js.map +1 -0
- package/dist/cli/src/client.js +1002 -0
- package/dist/cli/src/client.js.map +1 -0
- package/dist/cli/src/constants.js +37 -0
- package/dist/cli/src/constants.js.map +1 -0
- package/dist/cli/src/core/DAPBase.js +313 -0
- package/dist/cli/src/core/DAPBase.js.map +1 -0
- package/dist/cli/src/core/DAPClient.js +173 -0
- package/dist/cli/src/core/DAPClient.js.map +1 -0
- package/dist/cli/src/core/TransportBase.js +131 -0
- package/dist/cli/src/core/TransportBase.js.map +1 -0
- package/dist/cli/src/core/TransportWebSocket.js +492 -0
- package/dist/cli/src/core/TransportWebSocket.js.map +1 -0
- package/dist/cli/src/exceptions/index.js +109 -0
- package/dist/cli/src/exceptions/index.js.map +1 -0
- package/dist/cli/src/index.js +56 -0
- package/dist/cli/src/index.js.map +1 -0
- package/dist/cli/src/schema/Doc.js +79 -0
- package/dist/cli/src/schema/Doc.js.map +1 -0
- package/dist/cli/src/schema/DocFilter.js +133 -0
- package/dist/cli/src/schema/DocFilter.js.map +1 -0
- package/dist/cli/src/schema/DocGroup.js +235 -0
- package/dist/cli/src/schema/DocGroup.js.map +1 -0
- package/dist/cli/src/schema/DocMetadata.js +57 -0
- package/dist/cli/src/schema/DocMetadata.js.map +1 -0
- package/dist/cli/src/schema/Question.js +414 -0
- package/dist/cli/src/schema/Question.js.map +1 -0
- package/dist/cli/src/schema/index.js +50 -0
- package/dist/cli/src/schema/index.js.map +1 -0
- package/dist/cli/src/types/client.js +26 -0
- package/dist/cli/src/types/client.js.map +1 -0
- package/dist/cli/src/types/data.js +26 -0
- package/dist/cli/src/types/data.js.map +1 -0
- package/dist/cli/src/types/events.js +119 -0
- package/dist/cli/src/types/events.js.map +1 -0
- package/dist/cli/src/types/index.js +50 -0
- package/dist/cli/src/types/index.js.map +1 -0
- package/dist/cli/src/types/pipeline.js +26 -0
- package/dist/cli/src/types/pipeline.js.map +1 -0
- package/dist/cli/src/types/task.js +115 -0
- package/dist/cli/src/types/task.js.map +1 -0
- package/dist/esm/client.js +997 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants.js +34 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/core/DAPBase.js +309 -0
- package/dist/esm/core/DAPBase.js.map +1 -0
- package/dist/esm/core/DAPClient.js +169 -0
- package/dist/esm/core/DAPClient.js.map +1 -0
- package/dist/esm/core/TransportBase.js +127 -0
- package/dist/esm/core/TransportBase.js.map +1 -0
- package/dist/esm/core/TransportWebSocket.js +488 -0
- package/dist/esm/core/TransportWebSocket.js.map +1 -0
- package/dist/esm/exceptions/index.js +100 -0
- package/dist/esm/exceptions/index.js.map +1 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/schema/Doc.js +75 -0
- package/dist/esm/schema/Doc.js.map +1 -0
- package/dist/esm/schema/DocFilter.js +129 -0
- package/dist/esm/schema/DocFilter.js.map +1 -0
- package/dist/esm/schema/DocGroup.js +231 -0
- package/dist/esm/schema/DocGroup.js.map +1 -0
- package/dist/esm/schema/DocMetadata.js +53 -0
- package/dist/esm/schema/DocMetadata.js.map +1 -0
- package/dist/esm/schema/Question.js +409 -0
- package/dist/esm/schema/Question.js.map +1 -0
- package/dist/esm/schema/index.js +34 -0
- package/dist/esm/schema/index.js.map +1 -0
- package/dist/esm/types/client.js +25 -0
- package/dist/esm/types/client.js.map +1 -0
- package/dist/esm/types/data.js +25 -0
- package/dist/esm/types/data.js.map +1 -0
- package/dist/esm/types/events.js +116 -0
- package/dist/esm/types/events.js.map +1 -0
- package/dist/esm/types/index.js +34 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/pipeline.js +25 -0
- package/dist/esm/types/pipeline.js.map +1 -0
- package/dist/esm/types/task.js +112 -0
- package/dist/esm/types/task.js.map +1 -0
- package/dist/types/client.d.ts +395 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/constants.d.ts +34 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/core/DAPBase.d.ts +140 -0
- package/dist/types/core/DAPBase.d.ts.map +1 -0
- package/dist/types/core/DAPClient.d.ts +83 -0
- package/dist/types/core/DAPClient.d.ts.map +1 -0
- package/dist/types/core/TransportBase.d.ts +94 -0
- package/dist/types/core/TransportBase.d.ts.map +1 -0
- package/dist/types/core/TransportWebSocket.d.ts +78 -0
- package/dist/types/core/TransportWebSocket.d.ts.map +1 -0
- package/dist/types/exceptions/index.d.ts +81 -0
- package/dist/types/exceptions/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/schema/Doc.d.ts +69 -0
- package/dist/types/schema/Doc.d.ts.map +1 -0
- package/dist/types/schema/DocFilter.d.ts +101 -0
- package/dist/types/schema/DocFilter.d.ts.map +1 -0
- package/dist/types/schema/DocGroup.d.ts +113 -0
- package/dist/types/schema/DocGroup.d.ts.map +1 -0
- package/dist/types/schema/DocMetadata.d.ts +61 -0
- package/dist/types/schema/DocMetadata.d.ts.map +1 -0
- package/dist/types/schema/Question.d.ts +163 -0
- package/dist/types/schema/Question.d.ts.map +1 -0
- package/dist/types/schema/index.d.ts +34 -0
- package/dist/types/schema/index.d.ts.map +1 -0
- package/dist/types/types/client.d.ts +140 -0
- package/dist/types/types/client.d.ts.map +1 -0
- package/dist/types/types/data.d.ts +95 -0
- package/dist/types/types/data.d.ts.map +1 -0
- package/dist/types/types/events.d.ts +246 -0
- package/dist/types/types/events.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +34 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/pipeline.d.ts +61 -0
- package/dist/types/types/pipeline.d.ts.map +1 -0
- package/dist/types/types/task.d.ts +265 -0
- package/dist/types/types/task.d.ts.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Aparavi Development Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
# Aparavi Client TypeScript
|
|
2
|
+
|
|
3
|
+
A comprehensive TypeScript/JavaScript client library for the Aparavi data processing and AI platform. This package provides both a programmatic API and a command-line interface for managing Aparavi pipelines, uploading files, and processing data.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Pipeline Management**: Start, monitor, and control Aparavi data processing pipelines
|
|
8
|
+
- 📁 **File Upload**: Upload files with progress tracking and parallel processing
|
|
9
|
+
- 🤖 **AI Chat**: Interact with Aparavi's AI capabilities
|
|
10
|
+
- 📊 **Real-time Monitoring**: Monitor pipeline status and metrics in real-time
|
|
11
|
+
- 🔄 **Auto-reconnection**: Automatic reconnection with persistence support
|
|
12
|
+
- 📦 **Dual Module Support**: Works with both CommonJS and ES modules
|
|
13
|
+
- 🎯 **TypeScript Support**: Full TypeScript definitions included
|
|
14
|
+
- 🖥️ **CLI Tool**: Command-line interface for easy pipeline management
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install aparavi-client-typescript
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Using the CLI
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Install globally for CLI access
|
|
28
|
+
npm install -g aparavi-client-typescript
|
|
29
|
+
|
|
30
|
+
# Start a pipeline
|
|
31
|
+
aparavi start --pipeline ./my-pipeline.json --apikey YOUR_API_KEY
|
|
32
|
+
|
|
33
|
+
# Upload files
|
|
34
|
+
aparavi upload *.pdf --pipeline ./my-pipeline.json --apikey YOUR_API_KEY
|
|
35
|
+
|
|
36
|
+
# Monitor status
|
|
37
|
+
aparavi status --token TASK_TOKEN --apikey YOUR_API_KEY
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Using the Library
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
import { AparaviClient } from 'aparavi-client-typescript';
|
|
44
|
+
|
|
45
|
+
const client = new AparaviClient({
|
|
46
|
+
auth: 'your-api-key',
|
|
47
|
+
uri: 'wss://your-server.com' // optional
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await client.connect();
|
|
51
|
+
|
|
52
|
+
// Start a pipeline
|
|
53
|
+
const result = await client.use({
|
|
54
|
+
filepath: './my-pipeline.json'
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Send data
|
|
58
|
+
const response = await client.send(result.token, "Hello, Aparavi!");
|
|
59
|
+
|
|
60
|
+
await client.disconnect();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
### Environment Variables
|
|
66
|
+
|
|
67
|
+
Create a `.env` file in your project:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
APARAVI_APIKEY=your-api-key-here
|
|
71
|
+
APARAVI_URI=wss://your-server.com
|
|
72
|
+
APARAVI_PIPELINE=./my-pipeline.json
|
|
73
|
+
APARAVI_TOKEN=existing-task-token
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Client Configuration
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
const client = new AparaviClient({
|
|
80
|
+
auth: 'your-api-key', // Required: API key
|
|
81
|
+
uri: 'wss://your-server.com', // Optional: Server URI
|
|
82
|
+
persist: true, // Optional: Auto-reconnect
|
|
83
|
+
reconnectDelay: 1000, // Optional: Reconnect delay (ms)
|
|
84
|
+
onEvent: (event) => console.log(event), // Optional: Event handler
|
|
85
|
+
onConnected: () => console.log('Connected!'),
|
|
86
|
+
onDisconnected: (reason) => console.log('Disconnected:', reason),
|
|
87
|
+
env: { // Optional: Custom environment
|
|
88
|
+
APARAVI_PROJECT_ID: 'my-project'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## API Reference
|
|
94
|
+
|
|
95
|
+
### Core Methods
|
|
96
|
+
|
|
97
|
+
#### Connection Management
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
// Connect to server
|
|
101
|
+
await client.connect();
|
|
102
|
+
|
|
103
|
+
// Check connection status
|
|
104
|
+
const isConnected = client.isConnected();
|
|
105
|
+
|
|
106
|
+
// Disconnect
|
|
107
|
+
await client.disconnect();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Pipeline Execution
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
// Start pipeline from file
|
|
114
|
+
const result = await client.use({
|
|
115
|
+
filepath: './pipeline.json',
|
|
116
|
+
threads: 4,
|
|
117
|
+
token: 'custom-token', // optional
|
|
118
|
+
args: ['--verbose'] // optional
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Start pipeline from object
|
|
122
|
+
const result = await client.use({
|
|
123
|
+
pipeline: {
|
|
124
|
+
source: "source_1",
|
|
125
|
+
components: [...]
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Get pipeline status
|
|
130
|
+
const status = await client.getTaskStatus(result.token);
|
|
131
|
+
|
|
132
|
+
// Terminate pipeline
|
|
133
|
+
await client.terminate(result.token);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Data Operations
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
139
|
+
// Send string data
|
|
140
|
+
const response = await client.send(token, "Hello, World!");
|
|
141
|
+
|
|
142
|
+
// Send binary data
|
|
143
|
+
const buffer = new TextEncoder().encode("Binary data");
|
|
144
|
+
const response = await client.send(token, buffer, {
|
|
145
|
+
filename: "data.txt",
|
|
146
|
+
size: buffer.length
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Upload multiple files
|
|
150
|
+
const files = [
|
|
151
|
+
{ file: fileObject1, mimetype: 'application/pdf' },
|
|
152
|
+
{ file: fileObject2, objinfo: { custom: 'metadata' } }
|
|
153
|
+
];
|
|
154
|
+
const results = await client.sendFiles(files, token, 5); // max 5 concurrent
|
|
155
|
+
|
|
156
|
+
// Create data pipe for streaming
|
|
157
|
+
const pipe = await client.pipe(token, { filename: 'stream.txt' });
|
|
158
|
+
await pipe.open();
|
|
159
|
+
await pipe.write(new TextEncoder().encode("Chunk 1"));
|
|
160
|
+
await pipe.write(new TextEncoder().encode("Chunk 2"));
|
|
161
|
+
const result = await pipe.close();
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### AI Chat
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
import { Question } from 'aparavi-client-typescript';
|
|
168
|
+
|
|
169
|
+
const question = new Question({
|
|
170
|
+
text: "What is the main topic of this document?",
|
|
171
|
+
context: "Please analyze the uploaded content"
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const response = await client.chat({
|
|
175
|
+
token: pipelineToken,
|
|
176
|
+
question: question
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Event Handling
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
// Subscribe to events
|
|
184
|
+
await client.setEvents(token, ['apaevt_status_update', 'apaevt_status_upload']);
|
|
185
|
+
|
|
186
|
+
// Handle events
|
|
187
|
+
client.onEvent = (event) => {
|
|
188
|
+
console.log('Event received:', event.event, event.body);
|
|
189
|
+
};
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### CLI Commands
|
|
193
|
+
|
|
194
|
+
#### Start Pipeline
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
aparavi start [options]
|
|
198
|
+
|
|
199
|
+
Options:
|
|
200
|
+
--pipeline <file> Pipeline configuration file
|
|
201
|
+
--token <token> Existing task token (optional)
|
|
202
|
+
--threads <num> Number of threads (default: 4)
|
|
203
|
+
--args <args...> Additional arguments
|
|
204
|
+
--apikey <key> API key
|
|
205
|
+
--host <hostname> Server hostname (default: localhost)
|
|
206
|
+
--port <port> Server port (default: 5565)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Upload Files
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
aparavi upload <files...> [options]
|
|
213
|
+
|
|
214
|
+
Arguments:
|
|
215
|
+
<files...> Files, wildcards, or directories to upload
|
|
216
|
+
|
|
217
|
+
Options:
|
|
218
|
+
--pipeline <file> Pipeline file to start new task
|
|
219
|
+
--token <token> Existing task token
|
|
220
|
+
--max-concurrent <num> Max concurrent uploads (default: 5)
|
|
221
|
+
--threads <num> Number of threads (default: 4)
|
|
222
|
+
--apikey <key> API key
|
|
223
|
+
--host <hostname> Server hostname (default: localhost)
|
|
224
|
+
--port <port> Server port (default: 5565)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Monitor Status
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
aparavi status [options]
|
|
231
|
+
|
|
232
|
+
Options:
|
|
233
|
+
--token <token> Task token to monitor
|
|
234
|
+
--apikey <key> API key
|
|
235
|
+
--host <hostname> Server hostname (default: localhost)
|
|
236
|
+
--port <port> Server port (default: 5565)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Stop Pipeline
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
aparavi stop [options]
|
|
243
|
+
|
|
244
|
+
Options:
|
|
245
|
+
--token <token> Task token to stop
|
|
246
|
+
--apikey <key> API key
|
|
247
|
+
--host <hostname> Server hostname (default: localhost)
|
|
248
|
+
--port <port> Server port (default: 5565)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Pipeline Configuration
|
|
252
|
+
|
|
253
|
+
### Example Pipeline (LlamaParse)
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
{
|
|
257
|
+
"pipeline": {
|
|
258
|
+
"source": "source_1",
|
|
259
|
+
"components": [
|
|
260
|
+
{
|
|
261
|
+
"id": "source_1",
|
|
262
|
+
"provider": "webhook",
|
|
263
|
+
"config": {
|
|
264
|
+
"key": "webhook://*",
|
|
265
|
+
"mode": "Source",
|
|
266
|
+
"parameters": {
|
|
267
|
+
"endpoint": "/pipe/process",
|
|
268
|
+
"port": 5566
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"id": "llamaparse_1",
|
|
274
|
+
"provider": "llamaparse",
|
|
275
|
+
"config": {
|
|
276
|
+
"llamaparse.api_key": "your-llamaparse-key",
|
|
277
|
+
"result_type": "markdown"
|
|
278
|
+
},
|
|
279
|
+
"input": [
|
|
280
|
+
{
|
|
281
|
+
"lane": "tags",
|
|
282
|
+
"from": "source_1"
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"id": "response_1",
|
|
288
|
+
"provider": "response",
|
|
289
|
+
"input": [
|
|
290
|
+
{
|
|
291
|
+
"lane": "text",
|
|
292
|
+
"from": "source_1"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"lane": "table",
|
|
296
|
+
"from": "llamaparse_1"
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Example Pipeline (OCR)
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"pipeline": {
|
|
310
|
+
"source": "source_1",
|
|
311
|
+
"components": [
|
|
312
|
+
{
|
|
313
|
+
"id": "source_1",
|
|
314
|
+
"provider": "filesys",
|
|
315
|
+
"config": {
|
|
316
|
+
"include": [
|
|
317
|
+
{
|
|
318
|
+
"path": "/path/to/files",
|
|
319
|
+
"ocr": true,
|
|
320
|
+
"classify": true,
|
|
321
|
+
"vectorize": false
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": "agetocr_1",
|
|
328
|
+
"provider": "agetocr",
|
|
329
|
+
"config": {
|
|
330
|
+
"api_key": "your-agetocr-key"
|
|
331
|
+
},
|
|
332
|
+
"input": [
|
|
333
|
+
{
|
|
334
|
+
"lane": "tags",
|
|
335
|
+
"from": "source_1"
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Complete Examples
|
|
345
|
+
|
|
346
|
+
### Document Processing Workflow
|
|
347
|
+
|
|
348
|
+
```javascript
|
|
349
|
+
import { AparaviClient } from 'aparavi-client-typescript';
|
|
350
|
+
|
|
351
|
+
async function processDocuments() {
|
|
352
|
+
const client = new AparaviClient({
|
|
353
|
+
auth: process.env.APARAVI_APIKEY,
|
|
354
|
+
persist: true,
|
|
355
|
+
onEvent: (event) => {
|
|
356
|
+
if (event.event === 'apaevt_status_update') {
|
|
357
|
+
console.log('Status:', event.body.state);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
try {
|
|
363
|
+
await client.connect();
|
|
364
|
+
|
|
365
|
+
// Start pipeline
|
|
366
|
+
const result = await client.use({
|
|
367
|
+
filepath: './llamaparse-pipeline.json',
|
|
368
|
+
threads: 4
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
console.log(`Pipeline started: ${result.token}`);
|
|
372
|
+
|
|
373
|
+
// Upload files
|
|
374
|
+
const files = [
|
|
375
|
+
{ file: document1, mimetype: 'application/pdf' },
|
|
376
|
+
{ file: document2, mimetype: 'application/pdf' }
|
|
377
|
+
];
|
|
378
|
+
|
|
379
|
+
const uploadResults = await client.sendFiles(files, result.token, 5);
|
|
380
|
+
console.log('Upload results:', uploadResults);
|
|
381
|
+
|
|
382
|
+
// Monitor until complete
|
|
383
|
+
let status;
|
|
384
|
+
do {
|
|
385
|
+
status = await client.getTaskStatus(result.token);
|
|
386
|
+
console.log(`Progress: ${status.completedCount}/${status.totalCount}`);
|
|
387
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
388
|
+
} while (status.state < 5);
|
|
389
|
+
|
|
390
|
+
console.log('Processing complete!');
|
|
391
|
+
|
|
392
|
+
} finally {
|
|
393
|
+
await client.disconnect();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
processDocuments();
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### AI Chat Integration
|
|
401
|
+
|
|
402
|
+
```javascript
|
|
403
|
+
import { AparaviClient, Question } from 'aparavi-client-typescript';
|
|
404
|
+
|
|
405
|
+
async function chatWithAI() {
|
|
406
|
+
const client = new AparaviClient({
|
|
407
|
+
auth: process.env.APARAVI_APIKEY
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
await client.connect();
|
|
411
|
+
|
|
412
|
+
// Start a chat-enabled pipeline
|
|
413
|
+
const result = await client.use({
|
|
414
|
+
filepath: './chat-pipeline.json'
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// Ask questions
|
|
418
|
+
const question = new Question({
|
|
419
|
+
text: "What are the key insights from the uploaded documents?",
|
|
420
|
+
context: "Please provide a summary of the main findings"
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
const response = await client.chat({
|
|
424
|
+
token: result.token,
|
|
425
|
+
question: question
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
console.log('AI Response:', response);
|
|
429
|
+
|
|
430
|
+
await client.disconnect();
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Error Handling
|
|
435
|
+
|
|
436
|
+
```javascript
|
|
437
|
+
try {
|
|
438
|
+
const result = await client.use({ filepath: './pipeline.json' });
|
|
439
|
+
} catch (error) {
|
|
440
|
+
if (error.message.includes('not found')) {
|
|
441
|
+
console.error('Pipeline file not found');
|
|
442
|
+
} else if (error.message.includes('authentication')) {
|
|
443
|
+
console.error('Invalid API key');
|
|
444
|
+
} else {
|
|
445
|
+
console.error('Pipeline execution failed:', error.message);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## TypeScript Support
|
|
451
|
+
|
|
452
|
+
The package includes full TypeScript definitions:
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
import { AparaviClient, PipelineConfig, TASK_STATUS } from 'aparavi-client-typescript';
|
|
456
|
+
|
|
457
|
+
const client: AparaviClient = new AparaviClient({
|
|
458
|
+
auth: 'your-api-key'
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
const status: TASK_STATUS = await client.getTaskStatus(token);
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## Browser Support
|
|
465
|
+
|
|
466
|
+
The client works in both Node.js and browser environments:
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
// Browser usage
|
|
470
|
+
import { AparaviClient } from 'aparavi-client-typescript';
|
|
471
|
+
|
|
472
|
+
const client = new AparaviClient({
|
|
473
|
+
auth: 'your-api-key',
|
|
474
|
+
uri: 'wss://your-server.com'
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
// File upload in browser
|
|
478
|
+
const fileInput = document.getElementById('fileInput');
|
|
479
|
+
const files = Array.from(fileInput.files).map(file => ({ file }));
|
|
480
|
+
|
|
481
|
+
const results = await client.sendFiles(files, token);
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
## Troubleshooting
|
|
485
|
+
|
|
486
|
+
### Common Issues
|
|
487
|
+
|
|
488
|
+
1. **Connection Failed**: Check your API key and server URI
|
|
489
|
+
2. **Pipeline Not Found**: Verify the pipeline file path and JSON format
|
|
490
|
+
3. **Upload Errors**: Ensure files are accessible and not too large
|
|
491
|
+
4. **Authentication Errors**: Verify your API key is correct
|
|
492
|
+
|
|
493
|
+
### Debug Mode
|
|
494
|
+
|
|
495
|
+
Enable debug logging:
|
|
496
|
+
|
|
497
|
+
```javascript
|
|
498
|
+
const client = new AparaviClient({
|
|
499
|
+
auth: 'your-api-key',
|
|
500
|
+
// Debug messages will be logged to console
|
|
501
|
+
});
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
## License
|
|
505
|
+
|
|
506
|
+
MIT License - see LICENSE file for details.
|
|
507
|
+
|
|
508
|
+
## Support
|
|
509
|
+
|
|
510
|
+
For support and documentation, visit:
|
|
511
|
+
- [Aparavi Documentation](https://docs.aparavi.com)
|
|
512
|
+
- [GitHub Issues](https://github.com/aparavi/aparavi-client-typescript/issues)
|
|
513
|
+
|
|
514
|
+
## Changelog
|
|
515
|
+
|
|
516
|
+
### v1.0.1
|
|
517
|
+
- Initial release
|
|
518
|
+
- Full TypeScript support
|
|
519
|
+
- CLI interface
|
|
520
|
+
- Pipeline management
|
|
521
|
+
- File upload with progress tracking
|
|
522
|
+
- AI chat integration
|
|
523
|
+
- Real-time monitoring
|
|
Binary file
|
|
Binary file
|