@runtypelabs/sdk 4.21.0 → 5.1.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/dist/index.cjs +4 -138
- package/dist/index.d.cts +918 -1022
- package/dist/index.d.ts +918 -1022
- package/dist/index.mjs +4 -137
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -789,7 +789,7 @@ var FlowResult = class {
|
|
|
789
789
|
/**
|
|
790
790
|
* @param options.unified - The response is a unified-vocabulary SSE stream
|
|
791
791
|
* (`/dispatch` since the unified-SSE cutover). Set by dispatch call sites;
|
|
792
|
-
* left unset by still-legacy
|
|
792
|
+
* left unset by the still-legacy eval stream producer.
|
|
793
793
|
*/
|
|
794
794
|
constructor(response, summary, options = {}) {
|
|
795
795
|
this.consumed = false;
|
|
@@ -872,6 +872,7 @@ var FlowResult = class {
|
|
|
872
872
|
* const analysis = await result.getResult('analyze screenshot') // ✗ undefined
|
|
873
873
|
* ```
|
|
874
874
|
*/
|
|
875
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK step results are intentionally untyped (FlowSummary.results is Map<string, any>); consumers narrow at the use site
|
|
875
876
|
async getResult(stepName) {
|
|
876
877
|
const summary = await this.ensureSummary();
|
|
877
878
|
if (summary.results.has(stepName)) {
|
|
@@ -892,6 +893,7 @@ var FlowResult = class {
|
|
|
892
893
|
* }
|
|
893
894
|
* ```
|
|
894
895
|
*/
|
|
896
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK step results are intentionally untyped (FlowSummary.results is Map<string, any>); consumers narrow at the use site
|
|
895
897
|
async getAllResults() {
|
|
896
898
|
const summary = await this.ensureSummary();
|
|
897
899
|
return summary.results;
|
|
@@ -3453,138 +3455,10 @@ var EvalsNamespace = class {
|
|
|
3453
3455
|
};
|
|
3454
3456
|
|
|
3455
3457
|
// src/prompts-namespace.ts
|
|
3456
|
-
var PromptRunner = class {
|
|
3457
|
-
constructor(getClient, promptId, options) {
|
|
3458
|
-
this.getClient = getClient;
|
|
3459
|
-
this.promptId = promptId;
|
|
3460
|
-
this.options = options;
|
|
3461
|
-
}
|
|
3462
|
-
/**
|
|
3463
|
-
* Execute the prompt with streaming response
|
|
3464
|
-
*
|
|
3465
|
-
* Streams the prompt response as it's generated.
|
|
3466
|
-
*
|
|
3467
|
-
* @example
|
|
3468
|
-
* ```typescript
|
|
3469
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3470
|
-
* recordId: 'rec_456'
|
|
3471
|
-
* }).stream()
|
|
3472
|
-
*
|
|
3473
|
-
* // Process with callbacks
|
|
3474
|
-
* await result.stream({
|
|
3475
|
-
* onStepDelta: (text) => process.stdout.write(text),
|
|
3476
|
-
* onFlowComplete: () => console.log('Done!'),
|
|
3477
|
-
* })
|
|
3478
|
-
* ```
|
|
3479
|
-
*/
|
|
3480
|
-
async stream(callbacks) {
|
|
3481
|
-
const client = this.getClient();
|
|
3482
|
-
const payload = this.buildPayload();
|
|
3483
|
-
payload.stream = true;
|
|
3484
|
-
const response = await client.requestStream(`/prompts/${this.promptId}/run`, {
|
|
3485
|
-
method: "POST",
|
|
3486
|
-
body: JSON.stringify(payload)
|
|
3487
|
-
});
|
|
3488
|
-
const result = new FlowResult(response);
|
|
3489
|
-
if (callbacks) {
|
|
3490
|
-
await result.stream(callbacks);
|
|
3491
|
-
}
|
|
3492
|
-
return result;
|
|
3493
|
-
}
|
|
3494
|
-
/**
|
|
3495
|
-
* Execute the prompt and wait for complete result
|
|
3496
|
-
*
|
|
3497
|
-
* Waits for the entire response before returning.
|
|
3498
|
-
*
|
|
3499
|
-
* @example
|
|
3500
|
-
* ```typescript
|
|
3501
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3502
|
-
* recordId: 'rec_456'
|
|
3503
|
-
* }).result()
|
|
3504
|
-
*
|
|
3505
|
-
* const output = await result.getResult('prompt')
|
|
3506
|
-
* console.log(output)
|
|
3507
|
-
* ```
|
|
3508
|
-
*/
|
|
3509
|
-
async result() {
|
|
3510
|
-
const client = this.getClient();
|
|
3511
|
-
const payload = this.buildPayload();
|
|
3512
|
-
payload.stream = true;
|
|
3513
|
-
const response = await client.requestStream(`/prompts/${this.promptId}/run`, {
|
|
3514
|
-
method: "POST",
|
|
3515
|
-
body: JSON.stringify(payload)
|
|
3516
|
-
});
|
|
3517
|
-
const result = new FlowResult(response);
|
|
3518
|
-
await result.getSummary();
|
|
3519
|
-
return result;
|
|
3520
|
-
}
|
|
3521
|
-
/**
|
|
3522
|
-
* Build the run payload
|
|
3523
|
-
*/
|
|
3524
|
-
buildPayload() {
|
|
3525
|
-
const payload = {};
|
|
3526
|
-
if (this.options.recordId) {
|
|
3527
|
-
payload.recordId = this.options.recordId;
|
|
3528
|
-
} else if (this.options.record) {
|
|
3529
|
-
payload.record = this.options.record;
|
|
3530
|
-
}
|
|
3531
|
-
if (this.options.modelOverride) {
|
|
3532
|
-
payload.modelOverride = this.options.modelOverride;
|
|
3533
|
-
}
|
|
3534
|
-
if (this.options.temperature !== void 0) {
|
|
3535
|
-
payload.temperature = this.options.temperature;
|
|
3536
|
-
}
|
|
3537
|
-
if (this.options.topP !== void 0) {
|
|
3538
|
-
payload.topP = this.options.topP;
|
|
3539
|
-
}
|
|
3540
|
-
if (this.options.topK !== void 0) {
|
|
3541
|
-
payload.topK = this.options.topK;
|
|
3542
|
-
}
|
|
3543
|
-
if (this.options.frequencyPenalty !== void 0) {
|
|
3544
|
-
payload.frequencyPenalty = this.options.frequencyPenalty;
|
|
3545
|
-
}
|
|
3546
|
-
if (this.options.presencePenalty !== void 0) {
|
|
3547
|
-
payload.presencePenalty = this.options.presencePenalty;
|
|
3548
|
-
}
|
|
3549
|
-
if (this.options.seed !== void 0) {
|
|
3550
|
-
payload.seed = this.options.seed;
|
|
3551
|
-
}
|
|
3552
|
-
if (this.options.maxTokens !== void 0) {
|
|
3553
|
-
payload.maxTokens = this.options.maxTokens;
|
|
3554
|
-
}
|
|
3555
|
-
if (this.options.storeResult !== void 0) {
|
|
3556
|
-
payload.storeResult = this.options.storeResult;
|
|
3557
|
-
}
|
|
3558
|
-
return payload;
|
|
3559
|
-
}
|
|
3560
|
-
};
|
|
3561
3458
|
var PromptsNamespace = class {
|
|
3562
3459
|
constructor(getClient) {
|
|
3563
3460
|
this.getClient = getClient;
|
|
3564
3461
|
}
|
|
3565
|
-
/**
|
|
3566
|
-
* Run a prompt
|
|
3567
|
-
*
|
|
3568
|
-
* Returns a PromptRunner with terminal methods:
|
|
3569
|
-
* - .stream() - Execute and stream results
|
|
3570
|
-
* - .result() - Execute and wait for complete result
|
|
3571
|
-
*
|
|
3572
|
-
* @example
|
|
3573
|
-
* ```typescript
|
|
3574
|
-
* // Stream the response
|
|
3575
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3576
|
-
* recordId: 'rec_456'
|
|
3577
|
-
* }).stream()
|
|
3578
|
-
*
|
|
3579
|
-
* // Get complete result
|
|
3580
|
-
* const result = await Runtype.prompts.run('prompt_123', {
|
|
3581
|
-
* record: { name: 'Test', metadata: { input: 'Hello' } }
|
|
3582
|
-
* }).result()
|
|
3583
|
-
* ```
|
|
3584
|
-
*/
|
|
3585
|
-
run(promptId, options = {}) {
|
|
3586
|
-
return new PromptRunner(this.getClient, promptId, options);
|
|
3587
|
-
}
|
|
3588
3462
|
/**
|
|
3589
3463
|
* Create a new prompt
|
|
3590
3464
|
*
|
|
@@ -5635,7 +5509,7 @@ var Runtype = class {
|
|
|
5635
5509
|
|
|
5636
5510
|
// src/version.ts
|
|
5637
5511
|
var FALLBACK_VERSION = "0.0.0";
|
|
5638
|
-
var SDK_VERSION = "
|
|
5512
|
+
var SDK_VERSION = "5.1.0".length > 0 ? "5.1.0" : FALLBACK_VERSION;
|
|
5639
5513
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
5640
5514
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
5641
5515
|
|
|
@@ -7758,12 +7632,6 @@ var PromptsEndpoint = class {
|
|
|
7758
7632
|
async delete(id) {
|
|
7759
7633
|
return this.client.delete(`/prompts/${id}`);
|
|
7760
7634
|
}
|
|
7761
|
-
/**
|
|
7762
|
-
* Run a prompt on a specific record
|
|
7763
|
-
*/
|
|
7764
|
-
async runOnRecord(id, recordId) {
|
|
7765
|
-
return this.client.post(`/prompts/${id}/run-on-record`, { recordId });
|
|
7766
|
-
}
|
|
7767
7635
|
/**
|
|
7768
7636
|
* Get flows using this prompt
|
|
7769
7637
|
*/
|
|
@@ -13314,7 +13182,6 @@ export {
|
|
|
13314
13182
|
ProductDriftError,
|
|
13315
13183
|
ProductEnsureConflictError,
|
|
13316
13184
|
ProductsNamespace,
|
|
13317
|
-
PromptRunner,
|
|
13318
13185
|
PromptsEndpoint,
|
|
13319
13186
|
PromptsNamespace,
|
|
13320
13187
|
ProviderKeysEndpoint,
|
package/package.json
CHANGED