cencori 1.2.0 → 1.2.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 +3 -51
- package/dist/ai/index.d.mts +32 -1
- package/dist/ai/index.d.ts +32 -1
- package/dist/ai/index.js +131 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/index.mjs +131 -0
- package/dist/ai/index.mjs.map +1 -1
- package/dist/compute/index.d.mts +1 -1
- package/dist/compute/index.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +138 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -7
- package/dist/index.mjs.map +1 -1
- package/dist/memory/index.d.mts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/storage/index.d.mts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +7 -7
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/index.mjs +7 -7
- package/dist/storage/index.mjs.map +1 -1
- package/dist/tanstack/index.d.mts +1 -1
- package/dist/tanstack/index.d.ts +1 -1
- package/dist/tanstack/index.js +3 -0
- package/dist/tanstack/index.js.map +1 -1
- package/dist/tanstack/index.mjs +3 -0
- package/dist/tanstack/index.mjs.map +1 -1
- package/dist/telemetry/index.d.mts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/{types-Cr0muEt3.d.mts → types-kh1whvNH.d.mts} +135 -1
- package/dist/{types-Cr0muEt3.d.ts → types-kh1whvNH.d.ts} +135 -1
- package/dist/workflow/index.d.mts +1 -1
- package/dist/workflow/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -352,6 +352,137 @@ var AINamespace = class {
|
|
|
352
352
|
latencyMs: data.latency_ms
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Send a request to the OpenAI-compatible Responses API.
|
|
357
|
+
* Supports built-in tools: web_search_preview, file_search, code_interpreter.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* const response = await cencori.ai.responses({
|
|
361
|
+
* model: 'gpt-4o',
|
|
362
|
+
* input: 'What is the weather in San Francisco?',
|
|
363
|
+
* tools: [{ type: 'web_search_preview' }]
|
|
364
|
+
* });
|
|
365
|
+
* console.log(response.output[0].content?.[0]?.text);
|
|
366
|
+
*/
|
|
367
|
+
async responses(request) {
|
|
368
|
+
const response = await fetch(`${this.config.baseUrl}/v1/responses`, {
|
|
369
|
+
method: "POST",
|
|
370
|
+
headers: {
|
|
371
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
372
|
+
"Content-Type": "application/json",
|
|
373
|
+
...this.config.headers
|
|
374
|
+
},
|
|
375
|
+
body: JSON.stringify({
|
|
376
|
+
model: request.model,
|
|
377
|
+
input: request.input,
|
|
378
|
+
instructions: request.instructions,
|
|
379
|
+
tools: request.tools,
|
|
380
|
+
tool_choice: request.tool_choice,
|
|
381
|
+
temperature: request.temperature,
|
|
382
|
+
max_output_tokens: request.max_output_tokens,
|
|
383
|
+
top_p: request.top_p,
|
|
384
|
+
store: request.store,
|
|
385
|
+
metadata: request.metadata,
|
|
386
|
+
previous_response_id: request.previous_response_id,
|
|
387
|
+
parallel_tool_calls: request.parallel_tool_calls,
|
|
388
|
+
truncation: request.truncation,
|
|
389
|
+
response_format: request.response_format,
|
|
390
|
+
include: request.include,
|
|
391
|
+
stream: false,
|
|
392
|
+
user: request.user
|
|
393
|
+
})
|
|
394
|
+
});
|
|
395
|
+
if (!response.ok) {
|
|
396
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
397
|
+
throw new Error(`Cencori API error: ${errorData.error || response.statusText}`);
|
|
398
|
+
}
|
|
399
|
+
return response.json();
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Stream responses from the Responses API via SSE.
|
|
403
|
+
* Yields parsed events as they arrive.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* for await (const event of cencori.ai.responsesStream({
|
|
407
|
+
* model: 'gpt-4o',
|
|
408
|
+
* input: 'Tell me about AI',
|
|
409
|
+
* })) {
|
|
410
|
+
* if (event.type === 'response.output_text.delta') {
|
|
411
|
+
* process.stdout.write(event.data.delta);
|
|
412
|
+
* }
|
|
413
|
+
* }
|
|
414
|
+
*/
|
|
415
|
+
async *responsesStream(request) {
|
|
416
|
+
const response = await fetch(`${this.config.baseUrl}/v1/responses`, {
|
|
417
|
+
method: "POST",
|
|
418
|
+
headers: {
|
|
419
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
420
|
+
"Content-Type": "application/json",
|
|
421
|
+
...this.config.headers
|
|
422
|
+
},
|
|
423
|
+
body: JSON.stringify({
|
|
424
|
+
model: request.model,
|
|
425
|
+
input: request.input,
|
|
426
|
+
instructions: request.instructions,
|
|
427
|
+
tools: request.tools,
|
|
428
|
+
tool_choice: request.tool_choice,
|
|
429
|
+
temperature: request.temperature,
|
|
430
|
+
max_output_tokens: request.max_output_tokens,
|
|
431
|
+
top_p: request.top_p,
|
|
432
|
+
store: request.store,
|
|
433
|
+
metadata: request.metadata,
|
|
434
|
+
previous_response_id: request.previous_response_id,
|
|
435
|
+
parallel_tool_calls: request.parallel_tool_calls,
|
|
436
|
+
truncation: request.truncation,
|
|
437
|
+
response_format: request.response_format,
|
|
438
|
+
include: request.include,
|
|
439
|
+
stream: true,
|
|
440
|
+
user: request.user
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
if (!response.ok) {
|
|
444
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
445
|
+
throw new Error(`Cencori API error: ${errorData.error || response.statusText}`);
|
|
446
|
+
}
|
|
447
|
+
if (!response.body) {
|
|
448
|
+
throw new Error("Response body is null");
|
|
449
|
+
}
|
|
450
|
+
const reader = response.body.getReader();
|
|
451
|
+
const decoder = new TextDecoder();
|
|
452
|
+
let buffer = "";
|
|
453
|
+
let eventType = "";
|
|
454
|
+
try {
|
|
455
|
+
while (true) {
|
|
456
|
+
const { done, value } = await reader.read();
|
|
457
|
+
if (done) break;
|
|
458
|
+
buffer += decoder.decode(value, { stream: true });
|
|
459
|
+
const lines = buffer.split("\n");
|
|
460
|
+
buffer = lines.pop() || "";
|
|
461
|
+
for (const line of lines) {
|
|
462
|
+
if (line.trim() === "") {
|
|
463
|
+
eventType = "";
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (line.startsWith("event: ")) {
|
|
467
|
+
eventType = line.slice(7).trim();
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (line.startsWith("data: ")) {
|
|
471
|
+
const data = line.slice(6).trim();
|
|
472
|
+
if (!data) continue;
|
|
473
|
+
try {
|
|
474
|
+
const parsed = JSON.parse(data);
|
|
475
|
+
yield { type: eventType || "message", data: parsed };
|
|
476
|
+
} catch {
|
|
477
|
+
}
|
|
478
|
+
eventType = "";
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
} finally {
|
|
483
|
+
reader.releaseLock();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
355
486
|
/**
|
|
356
487
|
* Stream RAG responses with automatic memory context
|
|
357
488
|
*
|
|
@@ -505,7 +636,7 @@ var VectorsNamespace = class {
|
|
|
505
636
|
*/
|
|
506
637
|
async search(query, options) {
|
|
507
638
|
throw new Error(
|
|
508
|
-
`cencori.storage.vectors.search() is coming soon! Join our waitlist at https://cencori.com/
|
|
639
|
+
`cencori.storage.vectors.search() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
509
640
|
);
|
|
510
641
|
}
|
|
511
642
|
/**
|
|
@@ -515,7 +646,7 @@ var VectorsNamespace = class {
|
|
|
515
646
|
*/
|
|
516
647
|
async upsert(vectors) {
|
|
517
648
|
throw new Error(
|
|
518
|
-
`cencori.storage.vectors.upsert() is coming soon! Join our waitlist at https://cencori.com/
|
|
649
|
+
`cencori.storage.vectors.upsert() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
519
650
|
);
|
|
520
651
|
}
|
|
521
652
|
/**
|
|
@@ -525,7 +656,7 @@ var VectorsNamespace = class {
|
|
|
525
656
|
*/
|
|
526
657
|
async delete(ids) {
|
|
527
658
|
throw new Error(
|
|
528
|
-
`cencori.storage.vectors.delete() is coming soon! Join our waitlist at https://cencori.com/
|
|
659
|
+
`cencori.storage.vectors.delete() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
529
660
|
);
|
|
530
661
|
}
|
|
531
662
|
};
|
|
@@ -537,7 +668,7 @@ var KnowledgeNamespace = class {
|
|
|
537
668
|
*/
|
|
538
669
|
async query(question) {
|
|
539
670
|
throw new Error(
|
|
540
|
-
`cencori.storage.knowledge.query() is coming soon! Join our waitlist at https://cencori.com/
|
|
671
|
+
`cencori.storage.knowledge.query() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
541
672
|
);
|
|
542
673
|
}
|
|
543
674
|
/**
|
|
@@ -547,7 +678,7 @@ var KnowledgeNamespace = class {
|
|
|
547
678
|
*/
|
|
548
679
|
async add(documents) {
|
|
549
680
|
throw new Error(
|
|
550
|
-
`cencori.storage.knowledge.add() is coming soon! Join our waitlist at https://cencori.com/
|
|
681
|
+
`cencori.storage.knowledge.add() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
551
682
|
);
|
|
552
683
|
}
|
|
553
684
|
};
|
|
@@ -559,7 +690,7 @@ var FilesNamespace = class {
|
|
|
559
690
|
*/
|
|
560
691
|
async upload(file, name) {
|
|
561
692
|
throw new Error(
|
|
562
|
-
`cencori.storage.files.upload() is coming soon! Join our waitlist at https://cencori.com/
|
|
693
|
+
`cencori.storage.files.upload() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
563
694
|
);
|
|
564
695
|
}
|
|
565
696
|
/**
|
|
@@ -569,7 +700,7 @@ var FilesNamespace = class {
|
|
|
569
700
|
*/
|
|
570
701
|
async process(fileId) {
|
|
571
702
|
throw new Error(
|
|
572
|
-
`cencori.storage.files.process() is coming soon! Join our waitlist at https://cencori.com/
|
|
703
|
+
`cencori.storage.files.process() is coming soon! Join our waitlist at https://cencori.com/memory`
|
|
573
704
|
);
|
|
574
705
|
}
|
|
575
706
|
};
|