@discomedia/utils 1.0.34 → 1.0.35
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-frontend.cjs +86 -14
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +86 -14
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +86 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +86 -14
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +86 -14
- package/dist/test.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2395,7 +2395,7 @@ const safeJSON = (text) => {
|
|
|
2395
2395
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2396
2396
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
2397
2397
|
|
|
2398
|
-
const VERSION = '5.
|
|
2398
|
+
const VERSION = '5.22.0'; // x-release-please-version
|
|
2399
2399
|
|
|
2400
2400
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2401
2401
|
const isRunningInBrowser = () => {
|
|
@@ -5798,15 +5798,18 @@ class TranscriptionSessions extends APIResource {
|
|
|
5798
5798
|
}
|
|
5799
5799
|
|
|
5800
5800
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5801
|
-
|
|
5801
|
+
/**
|
|
5802
|
+
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
|
|
5803
|
+
*/
|
|
5804
|
+
let Realtime$1 = class Realtime extends APIResource {
|
|
5802
5805
|
constructor() {
|
|
5803
5806
|
super(...arguments);
|
|
5804
5807
|
this.sessions = new Sessions(this._client);
|
|
5805
5808
|
this.transcriptionSessions = new TranscriptionSessions(this._client);
|
|
5806
5809
|
}
|
|
5807
|
-
}
|
|
5808
|
-
Realtime.Sessions = Sessions;
|
|
5809
|
-
Realtime.TranscriptionSessions = TranscriptionSessions;
|
|
5810
|
+
};
|
|
5811
|
+
Realtime$1.Sessions = Sessions;
|
|
5812
|
+
Realtime$1.TranscriptionSessions = TranscriptionSessions;
|
|
5810
5813
|
|
|
5811
5814
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
5812
5815
|
/**
|
|
@@ -6744,12 +6747,12 @@ Threads.Messages = Messages;
|
|
|
6744
6747
|
class Beta extends APIResource {
|
|
6745
6748
|
constructor() {
|
|
6746
6749
|
super(...arguments);
|
|
6747
|
-
this.realtime = new Realtime(this._client);
|
|
6750
|
+
this.realtime = new Realtime$1(this._client);
|
|
6748
6751
|
this.assistants = new Assistants(this._client);
|
|
6749
6752
|
this.threads = new Threads(this._client);
|
|
6750
6753
|
}
|
|
6751
6754
|
}
|
|
6752
|
-
Beta.Realtime = Realtime;
|
|
6755
|
+
Beta.Realtime = Realtime$1;
|
|
6753
6756
|
Beta.Assistants = Assistants;
|
|
6754
6757
|
Beta.Threads = Threads;
|
|
6755
6758
|
|
|
@@ -7510,6 +7513,25 @@ class Moderations extends APIResource {
|
|
|
7510
7513
|
}
|
|
7511
7514
|
}
|
|
7512
7515
|
|
|
7516
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7517
|
+
class ClientSecrets extends APIResource {
|
|
7518
|
+
/**
|
|
7519
|
+
* Create a Realtime client secret with an associated session configuration.
|
|
7520
|
+
*/
|
|
7521
|
+
create(body, options) {
|
|
7522
|
+
return this._client.post('/realtime/client_secrets', { body, ...options });
|
|
7523
|
+
}
|
|
7524
|
+
}
|
|
7525
|
+
|
|
7526
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7527
|
+
class Realtime extends APIResource {
|
|
7528
|
+
constructor() {
|
|
7529
|
+
super(...arguments);
|
|
7530
|
+
this.clientSecrets = new ClientSecrets(this._client);
|
|
7531
|
+
}
|
|
7532
|
+
}
|
|
7533
|
+
Realtime.ClientSecrets = ClientSecrets;
|
|
7534
|
+
|
|
7513
7535
|
function maybeParseResponse(response, params) {
|
|
7514
7536
|
if (!params || !hasAutoParseableInput(params)) {
|
|
7515
7537
|
return {
|
|
@@ -7760,8 +7782,16 @@ class ResponseStream extends EventStream {
|
|
|
7760
7782
|
if (!output) {
|
|
7761
7783
|
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
7762
7784
|
}
|
|
7763
|
-
|
|
7764
|
-
|
|
7785
|
+
const type = output.type;
|
|
7786
|
+
const part = event.part;
|
|
7787
|
+
if (type === 'message' && part.type !== 'reasoning_text') {
|
|
7788
|
+
output.content.push(part);
|
|
7789
|
+
}
|
|
7790
|
+
else if (type === 'reasoning' && part.type === 'reasoning_text') {
|
|
7791
|
+
if (!output.content) {
|
|
7792
|
+
output.content = [];
|
|
7793
|
+
}
|
|
7794
|
+
output.content.push(part);
|
|
7765
7795
|
}
|
|
7766
7796
|
break;
|
|
7767
7797
|
}
|
|
@@ -7792,6 +7822,23 @@ class ResponseStream extends EventStream {
|
|
|
7792
7822
|
}
|
|
7793
7823
|
break;
|
|
7794
7824
|
}
|
|
7825
|
+
case 'response.reasoning_text.delta': {
|
|
7826
|
+
const output = snapshot.output[event.output_index];
|
|
7827
|
+
if (!output) {
|
|
7828
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
7829
|
+
}
|
|
7830
|
+
if (output.type === 'reasoning') {
|
|
7831
|
+
const content = output.content?.[event.content_index];
|
|
7832
|
+
if (!content) {
|
|
7833
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
7834
|
+
}
|
|
7835
|
+
if (content.type !== 'reasoning_text') {
|
|
7836
|
+
throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
|
|
7837
|
+
}
|
|
7838
|
+
content.text += event.delta;
|
|
7839
|
+
}
|
|
7840
|
+
break;
|
|
7841
|
+
}
|
|
7795
7842
|
case 'response.completed': {
|
|
7796
7843
|
__classPrivateFieldSet(this, _ResponseStream_currentResponseSnapshot, event.response);
|
|
7797
7844
|
break;
|
|
@@ -8516,11 +8563,12 @@ class OpenAI {
|
|
|
8516
8563
|
this.batches = new Batches(this);
|
|
8517
8564
|
this.uploads = new Uploads(this);
|
|
8518
8565
|
this.responses = new Responses(this);
|
|
8566
|
+
this.realtime = new Realtime(this);
|
|
8519
8567
|
this.conversations = new Conversations(this);
|
|
8520
8568
|
this.evals = new Evals(this);
|
|
8521
8569
|
this.containers = new Containers(this);
|
|
8522
8570
|
if (apiKey === undefined) {
|
|
8523
|
-
throw new OpenAIError(
|
|
8571
|
+
throw new OpenAIError('Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.');
|
|
8524
8572
|
}
|
|
8525
8573
|
const options = {
|
|
8526
8574
|
apiKey,
|
|
@@ -8548,7 +8596,7 @@ class OpenAI {
|
|
|
8548
8596
|
this.fetch = options.fetch ?? getDefaultFetch();
|
|
8549
8597
|
__classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
|
|
8550
8598
|
this._options = options;
|
|
8551
|
-
this.apiKey = apiKey;
|
|
8599
|
+
this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
|
|
8552
8600
|
this.organization = organization;
|
|
8553
8601
|
this.project = project;
|
|
8554
8602
|
this.webhookSecret = webhookSecret;
|
|
@@ -8595,6 +8643,27 @@ class OpenAI {
|
|
|
8595
8643
|
makeStatusError(status, error, message, headers) {
|
|
8596
8644
|
return APIError.generate(status, error, message, headers);
|
|
8597
8645
|
}
|
|
8646
|
+
async _callApiKey() {
|
|
8647
|
+
const apiKey = this._options.apiKey;
|
|
8648
|
+
if (typeof apiKey !== 'function')
|
|
8649
|
+
return false;
|
|
8650
|
+
let token;
|
|
8651
|
+
try {
|
|
8652
|
+
token = await apiKey();
|
|
8653
|
+
}
|
|
8654
|
+
catch (err) {
|
|
8655
|
+
if (err instanceof OpenAIError)
|
|
8656
|
+
throw err;
|
|
8657
|
+
throw new OpenAIError(`Failed to get token from 'apiKey' function: ${err.message}`,
|
|
8658
|
+
// @ts-ignore
|
|
8659
|
+
{ cause: err });
|
|
8660
|
+
}
|
|
8661
|
+
if (typeof token !== 'string' || !token) {
|
|
8662
|
+
throw new OpenAIError(`Expected 'apiKey' function argument to return a string but it returned ${token}`);
|
|
8663
|
+
}
|
|
8664
|
+
this.apiKey = token;
|
|
8665
|
+
return true;
|
|
8666
|
+
}
|
|
8598
8667
|
buildURL(path, query, defaultBaseURL) {
|
|
8599
8668
|
const baseURL = (!__classPrivateFieldGet(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
8600
8669
|
const url = isAbsoluteURL(path) ?
|
|
@@ -8612,7 +8681,9 @@ class OpenAI {
|
|
|
8612
8681
|
/**
|
|
8613
8682
|
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
8614
8683
|
*/
|
|
8615
|
-
async prepareOptions(options) {
|
|
8684
|
+
async prepareOptions(options) {
|
|
8685
|
+
await this._callApiKey();
|
|
8686
|
+
}
|
|
8616
8687
|
/**
|
|
8617
8688
|
* Used as a callback for mutating the given `RequestInit` object.
|
|
8618
8689
|
*
|
|
@@ -8671,7 +8742,7 @@ class OpenAI {
|
|
|
8671
8742
|
const controller = new AbortController();
|
|
8672
8743
|
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
|
8673
8744
|
const headersTime = Date.now();
|
|
8674
|
-
if (response instanceof Error) {
|
|
8745
|
+
if (response instanceof globalThis.Error) {
|
|
8675
8746
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
8676
8747
|
if (options.signal?.aborted) {
|
|
8677
8748
|
throw new APIUserAbortError();
|
|
@@ -8962,6 +9033,7 @@ OpenAI.Beta = Beta;
|
|
|
8962
9033
|
OpenAI.Batches = Batches;
|
|
8963
9034
|
OpenAI.Uploads = Uploads;
|
|
8964
9035
|
OpenAI.Responses = Responses;
|
|
9036
|
+
OpenAI.Realtime = Realtime;
|
|
8965
9037
|
OpenAI.Conversations = Conversations;
|
|
8966
9038
|
OpenAI.Evals = Evals;
|
|
8967
9039
|
OpenAI.Containers = Containers;
|
|
@@ -15773,7 +15845,7 @@ var config = {};
|
|
|
15773
15845
|
|
|
15774
15846
|
var main = {exports: {}};
|
|
15775
15847
|
|
|
15776
|
-
var version = "17.2.
|
|
15848
|
+
var version = "17.2.2";
|
|
15777
15849
|
var require$$4 = {
|
|
15778
15850
|
version: version};
|
|
15779
15851
|
|