graphor 0.15.1 → 0.16.0
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/CHANGELOG.md +18 -234
- package/README.md +162 -209
- package/client.d.mts.map +1 -1
- package/client.d.ts.map +1 -1
- package/client.js +2 -25
- package/client.js.map +1 -1
- package/client.mjs +2 -25
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/sources.d.mts +6 -0
- package/resources/sources.d.mts.map +1 -1
- package/resources/sources.d.ts +6 -0
- package/resources/sources.d.ts.map +1 -1
- package/resources/sources.js +2 -0
- package/resources/sources.js.map +1 -1
- package/resources/sources.mjs +2 -0
- package/resources/sources.mjs.map +1 -1
- package/src/client.ts +0 -23
- package/src/resources/sources.ts +7 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
<<<<<<< HEAD
|
|
1
2
|
# Graphor TypeScript SDK
|
|
3
|
+
=======
|
|
4
|
+
# Graphor TypeScript API Library
|
|
5
|
+
>>>>>>> origin/generated--merge-conflict
|
|
2
6
|
|
|
3
7
|
[)](https://npmjs.org/package/graphor)
|
|
4
8
|
[](https://www.typescriptlang.org/)
|
|
5
9
|
|
|
10
|
+
<<<<<<< HEAD
|
|
6
11
|
The official TypeScript SDK for the [Graphor](https://graphorlm.com) API. Build intelligent document applications with ease.
|
|
7
12
|
|
|
8
13
|
**Features:**
|
|
@@ -12,6 +17,22 @@ The official TypeScript SDK for the [Graphor](https://graphorlm.com) API. Build
|
|
|
12
17
|
- 🔍 **Semantic Search** — Retrieve relevant chunks for custom RAG pipelines
|
|
13
18
|
- 🔒 **Type Safety** — Complete TypeScript definitions for all params and responses
|
|
14
19
|
- 🌐 **Multi-Runtime** — Works in Node.js, Deno, Bun, and browsers
|
|
20
|
+
=======
|
|
21
|
+
This library provides convenient access to the Graphor REST API from server-side TypeScript or JavaScript.
|
|
22
|
+
|
|
23
|
+
The REST API documentation can be found on [docs.graphorlm.com](https://docs.graphorlm.com). The full API of this library can be found in [api.md](api.md).
|
|
24
|
+
|
|
25
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
|
26
|
+
>>>>>>> origin/generated--merge-conflict
|
|
27
|
+
|
|
28
|
+
## MCP Server
|
|
29
|
+
|
|
30
|
+
Use the Graphor MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
|
|
31
|
+
|
|
32
|
+
[](https://cursor.com/en-US/install-mcp?name=graphor-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImdyYXBob3ItbWNwIl0sImVudiI6eyJHUkFQSE9SX0FQSV9LRVkiOiJNeSBBUEkgS2V5In19)
|
|
33
|
+
[](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22graphor-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22graphor-mcp%22%5D%2C%22env%22%3A%7B%22GRAPHOR_API_KEY%22%3A%22My%20API%20Key%22%7D%7D)
|
|
34
|
+
|
|
35
|
+
> Note: You may need to set environment variables in your MCP client.
|
|
15
36
|
|
|
16
37
|
## Documentation
|
|
17
38
|
|
|
@@ -25,9 +46,25 @@ npm install graphor
|
|
|
25
46
|
|
|
26
47
|
Or with your preferred package manager:
|
|
27
48
|
|
|
49
|
+
<<<<<<< HEAD
|
|
28
50
|
```bash
|
|
29
51
|
yarn add graphor
|
|
30
52
|
pnpm add graphor
|
|
53
|
+
=======
|
|
54
|
+
The full API of this library can be found in [api.md](api.md).
|
|
55
|
+
|
|
56
|
+
<!-- prettier-ignore -->
|
|
57
|
+
```js
|
|
58
|
+
import Graphor from 'graphor';
|
|
59
|
+
|
|
60
|
+
const client = new Graphor({
|
|
61
|
+
apiKey: process.env['GRAPHOR_API_KEY'], // This is the default and can be omitted
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const response = await client.sources.ingestURL({ url: 'url' });
|
|
65
|
+
|
|
66
|
+
console.log(response.build_id);
|
|
67
|
+
>>>>>>> origin/generated--merge-conflict
|
|
31
68
|
```
|
|
32
69
|
|
|
33
70
|
## Quick Start
|
|
@@ -36,21 +73,28 @@ pnpm add graphor
|
|
|
36
73
|
import Graphor from 'graphor';
|
|
37
74
|
import fs from 'fs';
|
|
38
75
|
|
|
76
|
+
<<<<<<< HEAD
|
|
39
77
|
const client = new Graphor(); // Uses GRAPHOR_API_KEY env var
|
|
40
78
|
|
|
41
79
|
// Upload a document
|
|
42
80
|
const source = await client.sources.upload({ file: fs.createReadStream('document.pdf') });
|
|
43
81
|
console.log(`Uploaded: ${source.file_name}`);
|
|
44
82
|
|
|
45
|
-
// Process with a parsing strategy
|
|
46
|
-
await client.sources.parse({
|
|
47
|
-
file_name: source.file_name,
|
|
48
|
-
partition_method: 'graphorlm' // Options: basic (Fast), hi_res (Balanced), hi_res_ft (Accurate), mai (VLM), graphorlm (Agentic)
|
|
49
|
-
});
|
|
50
|
-
|
|
51
83
|
// Ask questions about your documents
|
|
52
84
|
const response = await client.sources.ask({ question: 'What are the main topics?' });
|
|
53
85
|
console.log(`Answer: ${response.answer}`);
|
|
86
|
+
=======
|
|
87
|
+
<!-- prettier-ignore -->
|
|
88
|
+
```ts
|
|
89
|
+
import Graphor from 'graphor';
|
|
90
|
+
|
|
91
|
+
const client = new Graphor({
|
|
92
|
+
apiKey: process.env['GRAPHOR_API_KEY'], // This is the default and can be omitted
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const params: Graphor.SourceIngestURLParams = { url: 'url' };
|
|
96
|
+
const response: Graphor.SourceIngestURLResponse = await client.sources.ingestURL(params);
|
|
97
|
+
>>>>>>> origin/generated--merge-conflict
|
|
54
98
|
```
|
|
55
99
|
|
|
56
100
|
## Authentication
|
|
@@ -232,6 +276,7 @@ import Graphor, { toFile } from 'graphor';
|
|
|
232
276
|
|
|
233
277
|
const client = new Graphor();
|
|
234
278
|
|
|
279
|
+
<<<<<<< HEAD
|
|
235
280
|
// Using fs.createReadStream (Node.js)
|
|
236
281
|
await client.sources.upload({ file: fs.createReadStream('/path/to/file') });
|
|
237
282
|
|
|
@@ -243,6 +288,20 @@ await client.sources.upload({ file: await fetch('https://somesite/file') });
|
|
|
243
288
|
|
|
244
289
|
// Using toFile helper
|
|
245
290
|
await client.sources.upload({ file: await toFile(Buffer.from('my bytes'), 'file') });
|
|
291
|
+
=======
|
|
292
|
+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
|
|
293
|
+
await client.sources.ingestFile({ file: fs.createReadStream('/path/to/file') });
|
|
294
|
+
|
|
295
|
+
// Or if you have the web `File` API you can pass a `File` instance:
|
|
296
|
+
await client.sources.ingestFile({ file: new File(['my bytes'], 'file') });
|
|
297
|
+
|
|
298
|
+
// You can also pass a `fetch` `Response`:
|
|
299
|
+
await client.sources.ingestFile({ file: await fetch('https://somesite/file') });
|
|
300
|
+
|
|
301
|
+
// Finally, if none of the above are convenient, you can use our `toFile` helper:
|
|
302
|
+
await client.sources.ingestFile({ file: await toFile(Buffer.from('my bytes'), 'file') });
|
|
303
|
+
await client.sources.ingestFile({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
|
|
304
|
+
>>>>>>> origin/generated--merge-conflict
|
|
246
305
|
```
|
|
247
306
|
|
|
248
307
|
## Error Handling
|
|
@@ -250,6 +309,7 @@ await client.sources.upload({ file: await toFile(Buffer.from('my bytes'), 'file'
|
|
|
250
309
|
```typescript
|
|
251
310
|
import Graphor from 'graphor';
|
|
252
311
|
|
|
312
|
+
<<<<<<< HEAD
|
|
253
313
|
const client = new Graphor();
|
|
254
314
|
|
|
255
315
|
try {
|
|
@@ -271,6 +331,19 @@ try {
|
|
|
271
331
|
throw err;
|
|
272
332
|
}
|
|
273
333
|
}
|
|
334
|
+
=======
|
|
335
|
+
<!-- prettier-ignore -->
|
|
336
|
+
```ts
|
|
337
|
+
const response = await client.sources.ingestURL({ url: 'url' }).catch(async (err) => {
|
|
338
|
+
if (err instanceof Graphor.APIError) {
|
|
339
|
+
console.log(err.status); // 400
|
|
340
|
+
console.log(err.name); // BadRequestError
|
|
341
|
+
console.log(err.headers); // {server: 'nginx', ...}
|
|
342
|
+
} else {
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
>>>>>>> origin/generated--merge-conflict
|
|
274
347
|
```
|
|
275
348
|
|
|
276
349
|
| Status Code | Error Type |
|
|
@@ -288,18 +361,39 @@ try {
|
|
|
288
361
|
|
|
289
362
|
### Retries
|
|
290
363
|
|
|
364
|
+
<<<<<<< HEAD
|
|
291
365
|
Requests are automatically retried twice with exponential backoff:
|
|
366
|
+
=======
|
|
367
|
+
Certain errors will be automatically retried 0 times by default, with a short exponential backoff.
|
|
368
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
369
|
+
429 Rate Limit, and >=500 Internal errors will all be retried by default.
|
|
370
|
+
>>>>>>> origin/generated--merge-conflict
|
|
292
371
|
|
|
293
372
|
```typescript
|
|
294
373
|
// Configure default retries
|
|
295
374
|
const client = new Graphor({ maxRetries: 5 });
|
|
296
375
|
|
|
376
|
+
<<<<<<< HEAD
|
|
297
377
|
// Or per-request
|
|
298
378
|
await client.sources.ask({ question: '...' }, { maxRetries: 3 });
|
|
379
|
+
=======
|
|
380
|
+
<!-- prettier-ignore -->
|
|
381
|
+
```js
|
|
382
|
+
// Configure the default for all requests:
|
|
383
|
+
const client = new Graphor({
|
|
384
|
+
maxRetries: 0, // default is 2
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// Or, configure per-request:
|
|
388
|
+
await client.sources.ingestURL({ url: 'url' }, {
|
|
389
|
+
maxRetries: 5,
|
|
390
|
+
});
|
|
391
|
+
>>>>>>> origin/generated--merge-conflict
|
|
299
392
|
```
|
|
300
393
|
|
|
301
394
|
### Timeouts
|
|
302
395
|
|
|
396
|
+
<<<<<<< HEAD
|
|
303
397
|
Default timeout is 60 seconds:
|
|
304
398
|
|
|
305
399
|
```typescript
|
|
@@ -329,16 +423,32 @@ console.log(`✅ Uploaded: ${source.file_name}`);
|
|
|
329
423
|
const processed = await client.sources.parse({
|
|
330
424
|
file_name: source.file_name,
|
|
331
425
|
partition_method: 'hi_res'
|
|
426
|
+
=======
|
|
427
|
+
Requests time out after 10 minutes by default. You can configure this with a `timeout` option:
|
|
428
|
+
|
|
429
|
+
<!-- prettier-ignore -->
|
|
430
|
+
```ts
|
|
431
|
+
// Configure the default for all requests:
|
|
432
|
+
const client = new Graphor({
|
|
433
|
+
timeout: 20 * 1000, // 20 seconds (default is 10 minutes)
|
|
434
|
+
>>>>>>> origin/generated--merge-conflict
|
|
332
435
|
});
|
|
333
436
|
console.log(`✅ Processed: ${processed.status}`);
|
|
334
437
|
|
|
438
|
+
<<<<<<< HEAD
|
|
335
439
|
// 3. Ask questions
|
|
336
440
|
const response = await client.sources.ask({
|
|
337
441
|
question: 'What are the key terms of this contract?',
|
|
338
442
|
file_names: [source.file_name]
|
|
443
|
+
=======
|
|
444
|
+
// Override per-request:
|
|
445
|
+
await client.sources.ingestURL({ url: 'url' }, {
|
|
446
|
+
timeout: 5 * 1000,
|
|
447
|
+
>>>>>>> origin/generated--merge-conflict
|
|
339
448
|
});
|
|
340
449
|
console.log(`📝 Answer: ${response.answer}`);
|
|
341
450
|
|
|
451
|
+
<<<<<<< HEAD
|
|
342
452
|
// 4. Extract structured data
|
|
343
453
|
const extracted = await client.sources.extract({
|
|
344
454
|
file_names: [source.file_name],
|
|
@@ -352,197 +462,7 @@ const extracted = await client.sources.extract({
|
|
|
352
462
|
total_value: { type: 'number' }
|
|
353
463
|
}
|
|
354
464
|
}
|
|
355
|
-
|
|
356
|
-
console.log(`📊 Extracted: ${JSON.stringify(extracted.structured_output)}`);
|
|
357
|
-
|
|
358
|
-
// 5. Build custom RAG
|
|
359
|
-
const chunks = await client.sources.retrieveChunks({
|
|
360
|
-
query: 'payment obligations',
|
|
361
|
-
file_names: [source.file_name]
|
|
362
|
-
});
|
|
363
|
-
console.log(`🔍 Found ${chunks.total} relevant chunks`);
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
## MCP Server
|
|
367
|
-
|
|
368
|
-
Use the Graphor MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
|
|
369
|
-
|
|
370
|
-
[](https://cursor.com/en-US/install-mcp?name=graphor-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImdyYXBob3ItbWNwIl0sImVudiI6eyJHUkFQSE9SX0FQSV9LRVkiOiJNeSBBUEkgS2V5In19)
|
|
371
|
-
[](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22graphor-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22graphor-mcp%22%5D%2C%22env%22%3A%7B%22GRAPHOR_API_KEY%22%3A%22My%20API%20Key%22%7D%7D)
|
|
372
|
-
|
|
373
|
-
Or manually add it to your MCP client's configuration:
|
|
374
|
-
|
|
375
|
-
```json
|
|
376
|
-
{
|
|
377
|
-
"mcpServers": {
|
|
378
|
-
"graphor_api": {
|
|
379
|
-
"command": "npx",
|
|
380
|
-
"args": ["-y", "graphor-mcp@latest"],
|
|
381
|
-
"env": {
|
|
382
|
-
"GRAPHOR_API_KEY": "grlm_your_api_key_here"
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
> Note: You may need to set environment variables in your MCP client.
|
|
390
|
-
|
|
391
|
-
### Remote MCP Server (Web Apps & Agentic Workflows)
|
|
392
|
-
|
|
393
|
-
For web-based AI clients (e.g. [Claude.ai](https://claude.ai)) or agentic frameworks (e.g. LangChain, CrewAI) that cannot run local `npx` processes, use the hosted remote MCP server. Authentication is handled via **OAuth** — a browser window will open for you to log in.
|
|
394
|
-
|
|
395
|
-
```
|
|
396
|
-
https://mcp.graphor.workers.dev/sse
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
**Web apps (e.g. Claude.ai)** — in Claude.ai, go to **Settings > Connectors > Add custom connector**, fill in the name and the remote MCP server URL. You will be redirected to log in through the OAuth flow:
|
|
400
|
-
|
|
401
|
-
The full API of this library can be found in [api.md](api.md).
|
|
402
|
-
|
|
403
|
-
<!-- prettier-ignore -->
|
|
404
|
-
```js
|
|
405
|
-
import Graphor from 'graphor';
|
|
406
|
-
|
|
407
|
-
const client = new Graphor({
|
|
408
|
-
apiKey: process.env['GRAPHOR_API_KEY'], // This is the default and can be omitted
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
const response = await client.sources.ingestURL({ url: 'url' });
|
|
412
|
-
|
|
413
|
-
console.log(response.build_id);
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
**Desktop clients (e.g. Claude Desktop)** — use [`mcp-remote`](https://www.npmjs.com/package/mcp-remote) as a local proxy:
|
|
417
|
-
|
|
418
|
-
```json
|
|
419
|
-
{
|
|
420
|
-
"mcpServers": {
|
|
421
|
-
"graphor_api": {
|
|
422
|
-
"command": "npx",
|
|
423
|
-
"args": ["mcp-remote", "https://mcp.graphor.workers.dev/sse"]
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
**Agentic workflows (e.g. LangChain)** — connect via SSE transport:
|
|
430
|
-
|
|
431
|
-
```typescript
|
|
432
|
-
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
|
|
433
|
-
|
|
434
|
-
const client = new MultiServerMCPClient({
|
|
435
|
-
graphor: {
|
|
436
|
-
url: "https://mcp.graphor.workers.dev/sse",
|
|
437
|
-
transport: "sse",
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
const params: Graphor.SourceIngestURLParams = { url: 'url' };
|
|
442
|
-
const response: Graphor.SourceIngestURLResponse = await client.sources.ingestURL(params);
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
446
|
-
|
|
447
|
-
## File uploads
|
|
448
|
-
|
|
449
|
-
Request parameters that correspond to file uploads can be passed in many different forms:
|
|
450
|
-
|
|
451
|
-
- `File` (or an object with the same structure)
|
|
452
|
-
- a `fetch` `Response` (or an object with the same structure)
|
|
453
|
-
- an `fs.ReadStream`
|
|
454
|
-
- the return value of our `toFile` helper
|
|
455
|
-
|
|
456
|
-
```ts
|
|
457
|
-
import fs from 'fs';
|
|
458
|
-
import Graphor, { toFile } from 'graphor';
|
|
459
|
-
|
|
460
|
-
const client = new Graphor();
|
|
461
|
-
|
|
462
|
-
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
|
|
463
|
-
await client.sources.ingestFile({ file: fs.createReadStream('/path/to/file') });
|
|
464
|
-
|
|
465
|
-
// Or if you have the web `File` API you can pass a `File` instance:
|
|
466
|
-
await client.sources.ingestFile({ file: new File(['my bytes'], 'file') });
|
|
467
|
-
|
|
468
|
-
// You can also pass a `fetch` `Response`:
|
|
469
|
-
await client.sources.ingestFile({ file: await fetch('https://somesite/file') });
|
|
470
|
-
|
|
471
|
-
// Finally, if none of the above are convenient, you can use our `toFile` helper:
|
|
472
|
-
await client.sources.ingestFile({ file: await toFile(Buffer.from('my bytes'), 'file') });
|
|
473
|
-
await client.sources.ingestFile({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
## Handling errors
|
|
477
|
-
|
|
478
|
-
When the library is unable to connect to the API,
|
|
479
|
-
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
|
|
480
|
-
a subclass of `APIError` will be thrown:
|
|
481
|
-
|
|
482
|
-
<!-- prettier-ignore -->
|
|
483
|
-
```ts
|
|
484
|
-
const response = await client.sources.ingestURL({ url: 'url' }).catch(async (err) => {
|
|
485
|
-
if (err instanceof Graphor.APIError) {
|
|
486
|
-
console.log(err.status); // 400
|
|
487
|
-
console.log(err.name); // BadRequestError
|
|
488
|
-
console.log(err.headers); // {server: 'nginx', ...}
|
|
489
|
-
} else {
|
|
490
|
-
throw err;
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
Error codes are as follows:
|
|
496
|
-
|
|
497
|
-
| Status Code | Error Type |
|
|
498
|
-
| ----------- | -------------------------- |
|
|
499
|
-
| 400 | `BadRequestError` |
|
|
500
|
-
| 401 | `AuthenticationError` |
|
|
501
|
-
| 403 | `PermissionDeniedError` |
|
|
502
|
-
| 404 | `NotFoundError` |
|
|
503
|
-
| 422 | `UnprocessableEntityError` |
|
|
504
|
-
| 429 | `RateLimitError` |
|
|
505
|
-
| >=500 | `InternalServerError` |
|
|
506
|
-
| N/A | `APIConnectionError` |
|
|
507
|
-
|
|
508
|
-
### Retries
|
|
509
|
-
|
|
510
|
-
Certain errors will be automatically retried 0 times by default, with a short exponential backoff.
|
|
511
|
-
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
512
|
-
429 Rate Limit, and >=500 Internal errors will all be retried by default.
|
|
513
|
-
|
|
514
|
-
You can use the `maxRetries` option to configure or disable this:
|
|
515
|
-
|
|
516
|
-
<!-- prettier-ignore -->
|
|
517
|
-
```js
|
|
518
|
-
// Configure the default for all requests:
|
|
519
|
-
const client = new Graphor({
|
|
520
|
-
maxRetries: 0, // default is 2
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
// Or, configure per-request:
|
|
524
|
-
await client.sources.ingestURL({ url: 'url' }, {
|
|
525
|
-
maxRetries: 5,
|
|
526
|
-
});
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
### Timeouts
|
|
530
|
-
|
|
531
|
-
Requests time out after 10 minutes by default. You can configure this with a `timeout` option:
|
|
532
|
-
|
|
533
|
-
<!-- prettier-ignore -->
|
|
534
|
-
```ts
|
|
535
|
-
// Configure the default for all requests:
|
|
536
|
-
const client = new Graphor({
|
|
537
|
-
timeout: 20 * 1000, // 20 seconds (default is 10 minutes)
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
// Override per-request:
|
|
541
|
-
await client.sources.ingestURL({ url: 'url' }, {
|
|
542
|
-
timeout: 5 * 1000,
|
|
543
|
-
});
|
|
544
|
-
```
|
|
545
|
-
|
|
465
|
+
=======
|
|
546
466
|
On timeout, an `APIConnectionTimeoutError` is thrown.
|
|
547
467
|
|
|
548
468
|
Note that requests which time out will be [retried twice by default](#retries).
|
|
@@ -590,9 +510,16 @@ import Graphor from 'graphor';
|
|
|
590
510
|
|
|
591
511
|
const client = new Graphor({
|
|
592
512
|
logLevel: 'debug', // Show all log messages
|
|
513
|
+
>>>>>>> origin/generated--merge-conflict
|
|
593
514
|
});
|
|
594
|
-
|
|
515
|
+
console.log(`📊 Extracted: ${JSON.stringify(extracted.structured_output)}`);
|
|
595
516
|
|
|
517
|
+
<<<<<<< HEAD
|
|
518
|
+
// 5. Build custom RAG
|
|
519
|
+
const chunks = await client.sources.retrieveChunks({
|
|
520
|
+
query: 'payment obligations',
|
|
521
|
+
file_names: [source.file_name]
|
|
522
|
+
=======
|
|
596
523
|
Available log levels, from most to least verbose:
|
|
597
524
|
|
|
598
525
|
- `'debug'` - Show debug messages, info, warnings, and errors
|
|
@@ -622,26 +549,51 @@ const logger = pino();
|
|
|
622
549
|
const client = new Graphor({
|
|
623
550
|
logger: logger.child({ name: 'Graphor' }),
|
|
624
551
|
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
552
|
+
>>>>>>> origin/generated--merge-conflict
|
|
625
553
|
});
|
|
554
|
+
console.log(`🔍 Found ${chunks.total} relevant chunks`);
|
|
626
555
|
```
|
|
627
556
|
|
|
628
|
-
|
|
557
|
+
## API Reference
|
|
629
558
|
|
|
630
|
-
|
|
631
|
-
endpoints, params, or response properties, the library can still be used.
|
|
559
|
+
### Sources
|
|
632
560
|
|
|
633
|
-
|
|
561
|
+
| Method | Description | Docs |
|
|
562
|
+
|--------|-------------|------|
|
|
563
|
+
| `sources.upload()` | Upload a local file | [📖](https://docs.graphorlm.com/sdk/sources/upload#upload-a-file) |
|
|
564
|
+
| `sources.uploadUrl()` | Upload from web URL | [📖](https://docs.graphorlm.com/sdk/sources/upload#upload-from-url) |
|
|
565
|
+
| `sources.uploadGithub()` | Upload from GitHub | [📖](https://docs.graphorlm.com/sdk/sources/upload#upload-from-github) |
|
|
566
|
+
| `sources.uploadYoutube()` | Upload from YouTube | [📖](https://docs.graphorlm.com/sdk/sources/upload#upload-from-youtube) |
|
|
567
|
+
| `sources.parse()` | Reprocess with different method | [📖](https://docs.graphorlm.com/sdk/sources/process) |
|
|
568
|
+
| `sources.list()` | List all sources | [📖](https://docs.graphorlm.com/sdk/sources/list) |
|
|
569
|
+
| `sources.delete()` | Delete a source | [📖](https://docs.graphorlm.com/sdk/sources/delete) |
|
|
570
|
+
| `sources.loadElements()` | Get parsed elements | [📖](https://docs.graphorlm.com/sdk/sources/list-elements) |
|
|
634
571
|
|
|
635
|
-
|
|
636
|
-
Options on the client, such as retries, will be respected when making these requests.
|
|
572
|
+
### Chat & AI
|
|
637
573
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
574
|
+
| Method | Description | Docs |
|
|
575
|
+
|--------|-------------|------|
|
|
576
|
+
| `sources.ask()` | Ask questions about documents | [📖](https://docs.graphorlm.com/sdk/chat) |
|
|
577
|
+
| `sources.extract()` | Extract structured data | [📖](https://docs.graphorlm.com/sdk/extract) |
|
|
578
|
+
| `sources.retrieveChunks()` | Retrieve chunks for RAG | [📖](https://docs.graphorlm.com/sdk/prebuilt-rag) |
|
|
579
|
+
|
|
580
|
+
## TypeScript Support
|
|
581
|
+
|
|
582
|
+
This library includes complete TypeScript definitions for all request params and response fields:
|
|
583
|
+
|
|
584
|
+
```typescript
|
|
585
|
+
import Graphor from 'graphor';
|
|
586
|
+
|
|
587
|
+
const client = new Graphor();
|
|
588
|
+
|
|
589
|
+
// Type-safe params and responses
|
|
590
|
+
const params: Graphor.SourceUploadParams = { file: fs.createReadStream('path/to/file') };
|
|
591
|
+
const source: Graphor.PublicSource = await client.sources.upload(params);
|
|
643
592
|
```
|
|
644
593
|
|
|
594
|
+
<<<<<<< HEAD
|
|
595
|
+
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
596
|
+
=======
|
|
645
597
|
#### Undocumented request params
|
|
646
598
|
|
|
647
599
|
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
|
|
@@ -760,6 +712,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
760
712
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
761
713
|
|
|
762
714
|
We are keen for your feedback; please open an [issue](https://www.github.com/synapseops/graphor-typescript-sdk/issues) with questions, bugs, or suggestions.
|
|
715
|
+
>>>>>>> origin/generated--merge-conflict
|
|
763
716
|
|
|
764
717
|
## Requirements
|
|
765
718
|
|
package/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE;YAIvE,EAAE,MAAM,EAAE,QAAQ,EAAE;OAKzB,KAAK,IAAI;OAGT,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EACL,OAAO,EACP,MAAM,EACN,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,wBAA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AO,EACvB,KAAK,MAAM,IAAI,MAAM,EACrB,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
|
package/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
var _Graphor_instances, _a, _Graphor_encoder,
|
|
3
|
+
var _Graphor_instances, _a, _Graphor_encoder, _Graphor_baseURLOverridden;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.Graphor = void 0;
|
|
6
6
|
const tslib_1 = require("./internal/tslib.js");
|
|
@@ -41,7 +41,6 @@ class Graphor {
|
|
|
41
41
|
constructor({ baseURL = (0, env_1.readEnv)('GRAPHOR_BASE_URL'), apiKey = (0, env_1.readEnv)('GRAPHOR_API_KEY'), ...opts } = {}) {
|
|
42
42
|
_Graphor_instances.add(this);
|
|
43
43
|
_Graphor_encoder.set(this, void 0);
|
|
44
|
-
_Graphor_undiciDispatcher.set(this, void 0);
|
|
45
44
|
this.sources = new API.Sources(this);
|
|
46
45
|
if (apiKey === undefined) {
|
|
47
46
|
throw new Errors.GraphorError("The GRAPHOR_API_KEY environment variable is missing or empty; either provide it, or instantiate the Graphor client with an apiKey option, like new Graphor({ apiKey: 'My API Key' }).");
|
|
@@ -64,7 +63,6 @@ class Graphor {
|
|
|
64
63
|
this.fetchOptions = options.fetchOptions;
|
|
65
64
|
this.maxRetries = options.maxRetries ?? 0;
|
|
66
65
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
67
|
-
tslib_1.__classPrivateFieldSet(this, _Graphor_undiciDispatcher, null, "f");
|
|
68
66
|
tslib_1.__classPrivateFieldSet(this, _Graphor_encoder, Opts.FallbackEncoder, "f");
|
|
69
67
|
this._options = options;
|
|
70
68
|
this.apiKey = apiKey;
|
|
@@ -280,27 +278,6 @@ class Graphor {
|
|
|
280
278
|
// See https://github.com/nodejs/undici/issues/2294
|
|
281
279
|
fetchOptions.method = method.toUpperCase();
|
|
282
280
|
}
|
|
283
|
-
// Node.js uses undici for fetch, which has its own bodyTimeout/headersTimeout
|
|
284
|
-
// defaults (300s). These can expire before the SDK's AbortController timeout,
|
|
285
|
-
// causing unexpected early timeouts. Sync undici's timeouts with the SDK timeout
|
|
286
|
-
// unless the user already provided a custom dispatcher.
|
|
287
|
-
if (!fetchOptions.dispatcher && typeof globalThis.process !== 'undefined') {
|
|
288
|
-
if (!tslib_1.__classPrivateFieldGet(this, _Graphor_undiciDispatcher, "f")) {
|
|
289
|
-
try {
|
|
290
|
-
const undici = await Function('return import("undici")')();
|
|
291
|
-
tslib_1.__classPrivateFieldSet(this, _Graphor_undiciDispatcher, new undici.Agent({
|
|
292
|
-
bodyTimeout: this.timeout,
|
|
293
|
-
headersTimeout: this.timeout,
|
|
294
|
-
}), "f");
|
|
295
|
-
}
|
|
296
|
-
catch {
|
|
297
|
-
// undici not available (browser, Deno, Bun) — no-op
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (tslib_1.__classPrivateFieldGet(this, _Graphor_undiciDispatcher, "f")) {
|
|
301
|
-
fetchOptions.dispatcher = tslib_1.__classPrivateFieldGet(this, _Graphor_undiciDispatcher, "f");
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
281
|
try {
|
|
305
282
|
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
306
283
|
return await this.fetch.call(undefined, url, fetchOptions);
|
|
@@ -462,7 +439,7 @@ class Graphor {
|
|
|
462
439
|
}
|
|
463
440
|
}
|
|
464
441
|
exports.Graphor = Graphor;
|
|
465
|
-
_a = Graphor, _Graphor_encoder = new WeakMap(),
|
|
442
|
+
_a = Graphor, _Graphor_encoder = new WeakMap(), _Graphor_instances = new WeakSet(), _Graphor_baseURLOverridden = function _Graphor_baseURLOverridden() {
|
|
466
443
|
return this.baseURL !== 'https://api.graphorlm.com/api/public/v1';
|
|
467
444
|
};
|
|
468
445
|
Graphor.Graphor = _a;
|