ai 3.2.39 → 3.2.41
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 +1 -1
- package/dist/index.d.mts +50 -27
- package/dist/index.d.ts +50 -27
- package/dist/index.js +438 -197
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +438 -197
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
@@ -19,6 +19,20 @@ type TelemetrySettings = {
|
|
19
19
|
* Enable or disable telemetry. Disabled by default while experimental.
|
20
20
|
*/
|
21
21
|
isEnabled?: boolean;
|
22
|
+
/**
|
23
|
+
* Enable or disable input recording. Enabled by default.
|
24
|
+
*
|
25
|
+
* You might want to disable input recording to avoid recording sensitive
|
26
|
+
* information, to reduce data transfers, or to increase performance.
|
27
|
+
*/
|
28
|
+
recordInputs?: boolean;
|
29
|
+
/**
|
30
|
+
* Enable or disable output recording. Enabled by default.
|
31
|
+
*
|
32
|
+
* You might want to disable output recording to avoid recording sensitive
|
33
|
+
* information, to reduce data transfers, or to increase performance.
|
34
|
+
*/
|
35
|
+
recordOutputs?: boolean;
|
22
36
|
/**
|
23
37
|
* Identifier for this function. Used to group telemetry data by function.
|
24
38
|
*/
|
@@ -856,7 +870,7 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
856
870
|
readonly warnings: StreamObjectResult<T>['warnings'];
|
857
871
|
readonly usage: StreamObjectResult<T>['usage'];
|
858
872
|
readonly rawResponse: StreamObjectResult<T>['rawResponse'];
|
859
|
-
constructor({ stream, warnings, rawResponse, schema, onFinish, rootSpan, doStreamSpan, }: {
|
873
|
+
constructor({ stream, warnings, rawResponse, schema, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
860
874
|
stream: ReadableStream<string | Omit<LanguageModelV1StreamPart, 'text-delta'>>;
|
861
875
|
warnings: StreamObjectResult<T>['warnings'];
|
862
876
|
rawResponse?: StreamObjectResult<T>['rawResponse'];
|
@@ -864,6 +878,7 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
864
878
|
onFinish: Parameters<typeof streamObject<T>>[0]['onFinish'];
|
865
879
|
rootSpan: Span;
|
866
880
|
doStreamSpan: Span;
|
881
|
+
telemetry: TelemetrySettings | undefined;
|
867
882
|
});
|
868
883
|
get object(): Promise<T>;
|
869
884
|
get partialObjectStream(): AsyncIterableStream<DeepPartial<T>>;
|
@@ -1505,13 +1520,14 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1505
1520
|
readonly toolCalls: StreamTextResult<TOOLS>['toolCalls'];
|
1506
1521
|
readonly toolResults: StreamTextResult<TOOLS>['toolResults'];
|
1507
1522
|
readonly rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1508
|
-
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, }: {
|
1523
|
+
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
1509
1524
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
1510
1525
|
warnings: StreamTextResult<TOOLS>['warnings'];
|
1511
1526
|
rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1512
1527
|
onFinish?: Parameters<typeof streamText>[0]['onFinish'];
|
1513
1528
|
rootSpan: Span;
|
1514
1529
|
doStreamSpan: Span;
|
1530
|
+
telemetry: TelemetrySettings | undefined;
|
1515
1531
|
});
|
1516
1532
|
/**
|
1517
1533
|
Split out a new stream from the original stream.
|
@@ -2223,6 +2239,31 @@ type InkeepChatResultCallbacks = {
|
|
2223
2239
|
type InkeepAIStreamCallbacksAndOptions = AIStreamCallbacksAndOptions & InkeepChatResultCallbacks;
|
2224
2240
|
declare function InkeepStream(res: Response, callbacks?: InkeepAIStreamCallbacksAndOptions): ReadableStream;
|
2225
2241
|
|
2242
|
+
/**
|
2243
|
+
* A stream wrapper to send custom JSON-encoded data back to the client.
|
2244
|
+
*/
|
2245
|
+
declare class StreamData {
|
2246
|
+
private encoder;
|
2247
|
+
private controller;
|
2248
|
+
stream: ReadableStream<Uint8Array>;
|
2249
|
+
private isClosed;
|
2250
|
+
private warningTimeout;
|
2251
|
+
constructor();
|
2252
|
+
close(): Promise<void>;
|
2253
|
+
append(value: JSONValue): void;
|
2254
|
+
appendMessageAnnotation(value: JSONValue): void;
|
2255
|
+
}
|
2256
|
+
/**
|
2257
|
+
* A TransformStream for LLMs that do not have their own transform stream handlers managing encoding (e.g. OpenAIStream has one for function call handling).
|
2258
|
+
* This assumes every chunk is a 'text' chunk.
|
2259
|
+
*/
|
2260
|
+
declare function createStreamDataTransformer(): TransformStream<any, any>;
|
2261
|
+
/**
|
2262
|
+
@deprecated Use `StreamData` instead.
|
2263
|
+
*/
|
2264
|
+
declare class experimental_StreamData extends StreamData {
|
2265
|
+
}
|
2266
|
+
|
2226
2267
|
type LangChainImageDetail = 'auto' | 'low' | 'high';
|
2227
2268
|
type LangChainMessageContentText = {
|
2228
2269
|
type: 'text';
|
@@ -2266,13 +2307,20 @@ The following streams are supported:
|
|
2266
2307
|
- `string` streams (LangChain `StringOutputParser` output)
|
2267
2308
|
*/
|
2268
2309
|
declare function toDataStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
|
2310
|
+
declare function toDataStreamResponse(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, options?: {
|
2311
|
+
init?: ResponseInit;
|
2312
|
+
data?: StreamData;
|
2313
|
+
callbacks?: AIStreamCallbacksAndOptions;
|
2314
|
+
}): Response;
|
2269
2315
|
|
2270
2316
|
declare const langchainAdapter_toAIStream: typeof toAIStream;
|
2271
2317
|
declare const langchainAdapter_toDataStream: typeof toDataStream;
|
2318
|
+
declare const langchainAdapter_toDataStreamResponse: typeof toDataStreamResponse;
|
2272
2319
|
declare namespace langchainAdapter {
|
2273
2320
|
export {
|
2274
2321
|
langchainAdapter_toAIStream as toAIStream,
|
2275
2322
|
langchainAdapter_toDataStream as toDataStream,
|
2323
|
+
langchainAdapter_toDataStreamResponse as toDataStreamResponse,
|
2276
2324
|
};
|
2277
2325
|
}
|
2278
2326
|
|
@@ -2369,31 +2417,6 @@ declare function ReplicateStream(res: Prediction, cb?: AIStreamCallbacksAndOptio
|
|
2369
2417
|
headers?: Record<string, string>;
|
2370
2418
|
}): Promise<ReadableStream>;
|
2371
2419
|
|
2372
|
-
/**
|
2373
|
-
* A stream wrapper to send custom JSON-encoded data back to the client.
|
2374
|
-
*/
|
2375
|
-
declare class StreamData {
|
2376
|
-
private encoder;
|
2377
|
-
private controller;
|
2378
|
-
stream: ReadableStream<Uint8Array>;
|
2379
|
-
private isClosed;
|
2380
|
-
private warningTimeout;
|
2381
|
-
constructor();
|
2382
|
-
close(): Promise<void>;
|
2383
|
-
append(value: JSONValue): void;
|
2384
|
-
appendMessageAnnotation(value: JSONValue): void;
|
2385
|
-
}
|
2386
|
-
/**
|
2387
|
-
* A TransformStream for LLMs that do not have their own transform stream handlers managing encoding (e.g. OpenAIStream has one for function call handling).
|
2388
|
-
* This assumes every chunk is a 'text' chunk.
|
2389
|
-
*/
|
2390
|
-
declare function createStreamDataTransformer(): TransformStream<any, any>;
|
2391
|
-
/**
|
2392
|
-
@deprecated Use `StreamData` instead.
|
2393
|
-
*/
|
2394
|
-
declare class experimental_StreamData extends StreamData {
|
2395
|
-
}
|
2396
|
-
|
2397
2420
|
/**
|
2398
2421
|
* A utility function to stream a ReadableStream to a Node.js response-like object.
|
2399
2422
|
*/
|
package/dist/index.d.ts
CHANGED
@@ -19,6 +19,20 @@ type TelemetrySettings = {
|
|
19
19
|
* Enable or disable telemetry. Disabled by default while experimental.
|
20
20
|
*/
|
21
21
|
isEnabled?: boolean;
|
22
|
+
/**
|
23
|
+
* Enable or disable input recording. Enabled by default.
|
24
|
+
*
|
25
|
+
* You might want to disable input recording to avoid recording sensitive
|
26
|
+
* information, to reduce data transfers, or to increase performance.
|
27
|
+
*/
|
28
|
+
recordInputs?: boolean;
|
29
|
+
/**
|
30
|
+
* Enable or disable output recording. Enabled by default.
|
31
|
+
*
|
32
|
+
* You might want to disable output recording to avoid recording sensitive
|
33
|
+
* information, to reduce data transfers, or to increase performance.
|
34
|
+
*/
|
35
|
+
recordOutputs?: boolean;
|
22
36
|
/**
|
23
37
|
* Identifier for this function. Used to group telemetry data by function.
|
24
38
|
*/
|
@@ -856,7 +870,7 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
856
870
|
readonly warnings: StreamObjectResult<T>['warnings'];
|
857
871
|
readonly usage: StreamObjectResult<T>['usage'];
|
858
872
|
readonly rawResponse: StreamObjectResult<T>['rawResponse'];
|
859
|
-
constructor({ stream, warnings, rawResponse, schema, onFinish, rootSpan, doStreamSpan, }: {
|
873
|
+
constructor({ stream, warnings, rawResponse, schema, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
860
874
|
stream: ReadableStream<string | Omit<LanguageModelV1StreamPart, 'text-delta'>>;
|
861
875
|
warnings: StreamObjectResult<T>['warnings'];
|
862
876
|
rawResponse?: StreamObjectResult<T>['rawResponse'];
|
@@ -864,6 +878,7 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
864
878
|
onFinish: Parameters<typeof streamObject<T>>[0]['onFinish'];
|
865
879
|
rootSpan: Span;
|
866
880
|
doStreamSpan: Span;
|
881
|
+
telemetry: TelemetrySettings | undefined;
|
867
882
|
});
|
868
883
|
get object(): Promise<T>;
|
869
884
|
get partialObjectStream(): AsyncIterableStream<DeepPartial<T>>;
|
@@ -1505,13 +1520,14 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1505
1520
|
readonly toolCalls: StreamTextResult<TOOLS>['toolCalls'];
|
1506
1521
|
readonly toolResults: StreamTextResult<TOOLS>['toolResults'];
|
1507
1522
|
readonly rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1508
|
-
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, }: {
|
1523
|
+
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
1509
1524
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
1510
1525
|
warnings: StreamTextResult<TOOLS>['warnings'];
|
1511
1526
|
rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1512
1527
|
onFinish?: Parameters<typeof streamText>[0]['onFinish'];
|
1513
1528
|
rootSpan: Span;
|
1514
1529
|
doStreamSpan: Span;
|
1530
|
+
telemetry: TelemetrySettings | undefined;
|
1515
1531
|
});
|
1516
1532
|
/**
|
1517
1533
|
Split out a new stream from the original stream.
|
@@ -2223,6 +2239,31 @@ type InkeepChatResultCallbacks = {
|
|
2223
2239
|
type InkeepAIStreamCallbacksAndOptions = AIStreamCallbacksAndOptions & InkeepChatResultCallbacks;
|
2224
2240
|
declare function InkeepStream(res: Response, callbacks?: InkeepAIStreamCallbacksAndOptions): ReadableStream;
|
2225
2241
|
|
2242
|
+
/**
|
2243
|
+
* A stream wrapper to send custom JSON-encoded data back to the client.
|
2244
|
+
*/
|
2245
|
+
declare class StreamData {
|
2246
|
+
private encoder;
|
2247
|
+
private controller;
|
2248
|
+
stream: ReadableStream<Uint8Array>;
|
2249
|
+
private isClosed;
|
2250
|
+
private warningTimeout;
|
2251
|
+
constructor();
|
2252
|
+
close(): Promise<void>;
|
2253
|
+
append(value: JSONValue): void;
|
2254
|
+
appendMessageAnnotation(value: JSONValue): void;
|
2255
|
+
}
|
2256
|
+
/**
|
2257
|
+
* A TransformStream for LLMs that do not have their own transform stream handlers managing encoding (e.g. OpenAIStream has one for function call handling).
|
2258
|
+
* This assumes every chunk is a 'text' chunk.
|
2259
|
+
*/
|
2260
|
+
declare function createStreamDataTransformer(): TransformStream<any, any>;
|
2261
|
+
/**
|
2262
|
+
@deprecated Use `StreamData` instead.
|
2263
|
+
*/
|
2264
|
+
declare class experimental_StreamData extends StreamData {
|
2265
|
+
}
|
2266
|
+
|
2226
2267
|
type LangChainImageDetail = 'auto' | 'low' | 'high';
|
2227
2268
|
type LangChainMessageContentText = {
|
2228
2269
|
type: 'text';
|
@@ -2266,13 +2307,20 @@ The following streams are supported:
|
|
2266
2307
|
- `string` streams (LangChain `StringOutputParser` output)
|
2267
2308
|
*/
|
2268
2309
|
declare function toDataStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
|
2310
|
+
declare function toDataStreamResponse(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, options?: {
|
2311
|
+
init?: ResponseInit;
|
2312
|
+
data?: StreamData;
|
2313
|
+
callbacks?: AIStreamCallbacksAndOptions;
|
2314
|
+
}): Response;
|
2269
2315
|
|
2270
2316
|
declare const langchainAdapter_toAIStream: typeof toAIStream;
|
2271
2317
|
declare const langchainAdapter_toDataStream: typeof toDataStream;
|
2318
|
+
declare const langchainAdapter_toDataStreamResponse: typeof toDataStreamResponse;
|
2272
2319
|
declare namespace langchainAdapter {
|
2273
2320
|
export {
|
2274
2321
|
langchainAdapter_toAIStream as toAIStream,
|
2275
2322
|
langchainAdapter_toDataStream as toDataStream,
|
2323
|
+
langchainAdapter_toDataStreamResponse as toDataStreamResponse,
|
2276
2324
|
};
|
2277
2325
|
}
|
2278
2326
|
|
@@ -2369,31 +2417,6 @@ declare function ReplicateStream(res: Prediction, cb?: AIStreamCallbacksAndOptio
|
|
2369
2417
|
headers?: Record<string, string>;
|
2370
2418
|
}): Promise<ReadableStream>;
|
2371
2419
|
|
2372
|
-
/**
|
2373
|
-
* A stream wrapper to send custom JSON-encoded data back to the client.
|
2374
|
-
*/
|
2375
|
-
declare class StreamData {
|
2376
|
-
private encoder;
|
2377
|
-
private controller;
|
2378
|
-
stream: ReadableStream<Uint8Array>;
|
2379
|
-
private isClosed;
|
2380
|
-
private warningTimeout;
|
2381
|
-
constructor();
|
2382
|
-
close(): Promise<void>;
|
2383
|
-
append(value: JSONValue): void;
|
2384
|
-
appendMessageAnnotation(value: JSONValue): void;
|
2385
|
-
}
|
2386
|
-
/**
|
2387
|
-
* A TransformStream for LLMs that do not have their own transform stream handlers managing encoding (e.g. OpenAIStream has one for function call handling).
|
2388
|
-
* This assumes every chunk is a 'text' chunk.
|
2389
|
-
*/
|
2390
|
-
declare function createStreamDataTransformer(): TransformStream<any, any>;
|
2391
|
-
/**
|
2392
|
-
@deprecated Use `StreamData` instead.
|
2393
|
-
*/
|
2394
|
-
declare class experimental_StreamData extends StreamData {
|
2395
|
-
}
|
2396
|
-
|
2397
2420
|
/**
|
2398
2421
|
* A utility function to stream a ReadableStream to a Node.js response-like object.
|
2399
2422
|
*/
|