@langchain/core 1.1.39 → 1.1.40-dev-1777073688723
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/callbacks/base.cjs +1 -1
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/language_models/base.cjs +1 -1
- package/dist/language_models/base.cjs.map +1 -1
- package/dist/language_models/base.js +1 -1
- package/dist/language_models/base.js.map +1 -1
- package/dist/language_models/chat_models.cjs +60 -0
- package/dist/language_models/chat_models.cjs.map +1 -1
- package/dist/language_models/chat_models.d.cts +55 -0
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts +55 -0
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/language_models/chat_models.js +60 -0
- package/dist/language_models/chat_models.js.map +1 -1
- package/dist/language_models/compat.cjs +224 -0
- package/dist/language_models/compat.cjs.map +1 -0
- package/dist/language_models/compat.d.cts +20 -0
- package/dist/language_models/compat.d.cts.map +1 -0
- package/dist/language_models/compat.d.ts +20 -0
- package/dist/language_models/compat.d.ts.map +1 -0
- package/dist/language_models/compat.js +216 -0
- package/dist/language_models/compat.js.map +1 -0
- package/dist/language_models/event.cjs +12 -0
- package/dist/language_models/event.cjs.map +1 -0
- package/dist/language_models/event.d.cts +141 -0
- package/dist/language_models/event.d.cts.map +1 -0
- package/dist/language_models/event.d.ts +141 -0
- package/dist/language_models/event.d.ts.map +1 -0
- package/dist/language_models/event.js +7 -0
- package/dist/language_models/event.js.map +1 -0
- package/dist/language_models/stream.cjs +362 -0
- package/dist/language_models/stream.cjs.map +1 -0
- package/dist/language_models/stream.d.cts +106 -0
- package/dist/language_models/stream.d.cts.map +1 -0
- package/dist/language_models/stream.d.ts +106 -0
- package/dist/language_models/stream.d.ts.map +1 -0
- package/dist/language_models/stream.js +351 -0
- package/dist/language_models/stream.js.map +1 -0
- package/dist/load/import_map.cjs +6 -0
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +8 -2
- package/dist/load/import_map.js.map +1 -1
- package/dist/load/map_keys.cjs +2 -2
- package/dist/messages/content/index.cjs.map +1 -1
- package/dist/messages/content/index.d.cts +5 -1
- package/dist/messages/content/index.d.cts.map +1 -1
- package/dist/messages/content/index.d.ts +5 -1
- package/dist/messages/content/index.d.ts.map +1 -1
- package/dist/messages/content/index.js.map +1 -1
- package/dist/messages/index.d.cts +2 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
- package/dist/prompts/template.cjs +1 -1
- package/dist/singletons/callbacks.cjs +1 -1
- package/dist/tracers/console.cjs +1 -1
- package/dist/types/type-utils.d.cts +2 -1
- package/dist/types/type-utils.d.cts.map +1 -1
- package/dist/types/type-utils.d.ts +2 -1
- package/dist/types/type-utils.d.ts.map +1 -1
- package/dist/utils/async_caller.cjs +3 -2
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.js +2 -1
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/event_source_parse.cjs +5 -12
- package/dist/utils/event_source_parse.cjs.map +1 -1
- package/dist/utils/event_source_parse.js +5 -12
- package/dist/utils/event_source_parse.js.map +1 -1
- package/package.json +34 -1
- package/agents.cjs +0 -1
- package/agents.d.cts +0 -1
- package/agents.d.ts +0 -1
- package/agents.js +0 -1
- package/caches.cjs +0 -1
- package/caches.d.cts +0 -1
- package/caches.d.ts +0 -1
- package/caches.js +0 -1
- package/callbacks/base.cjs +0 -1
- package/callbacks/base.d.cts +0 -1
- package/callbacks/base.d.ts +0 -1
- package/callbacks/base.js +0 -1
- package/callbacks/dispatch/web.cjs +0 -1
- package/callbacks/dispatch/web.d.cts +0 -1
- package/callbacks/dispatch/web.d.ts +0 -1
- package/callbacks/dispatch/web.js +0 -1
- package/callbacks/dispatch.cjs +0 -1
- package/callbacks/dispatch.d.cts +0 -1
- package/callbacks/dispatch.d.ts +0 -1
- package/callbacks/dispatch.js +0 -1
- package/callbacks/manager.cjs +0 -1
- package/callbacks/manager.d.cts +0 -1
- package/callbacks/manager.d.ts +0 -1
- package/callbacks/manager.js +0 -1
- package/callbacks/promises.cjs +0 -1
- package/callbacks/promises.d.cts +0 -1
- package/callbacks/promises.d.ts +0 -1
- package/callbacks/promises.js +0 -1
- package/chat_history.cjs +0 -1
- package/chat_history.d.cts +0 -1
- package/chat_history.d.ts +0 -1
- package/chat_history.js +0 -1
- package/context.cjs +0 -1
- package/context.d.cts +0 -1
- package/context.d.ts +0 -1
- package/context.js +0 -1
- package/document_loaders/base.cjs +0 -1
- package/document_loaders/base.d.cts +0 -1
- package/document_loaders/base.d.ts +0 -1
- package/document_loaders/base.js +0 -1
- package/document_loaders/langsmith.cjs +0 -1
- package/document_loaders/langsmith.d.cts +0 -1
- package/document_loaders/langsmith.d.ts +0 -1
- package/document_loaders/langsmith.js +0 -1
- package/documents.cjs +0 -1
- package/documents.d.cts +0 -1
- package/documents.d.ts +0 -1
- package/documents.js +0 -1
- package/embeddings.cjs +0 -1
- package/embeddings.d.cts +0 -1
- package/embeddings.d.ts +0 -1
- package/embeddings.js +0 -1
- package/errors.cjs +0 -1
- package/errors.d.cts +0 -1
- package/errors.d.ts +0 -1
- package/errors.js +0 -1
- package/example_selectors.cjs +0 -1
- package/example_selectors.d.cts +0 -1
- package/example_selectors.d.ts +0 -1
- package/example_selectors.js +0 -1
- package/indexing.cjs +0 -1
- package/indexing.d.cts +0 -1
- package/indexing.d.ts +0 -1
- package/indexing.js +0 -1
- package/language_models/base.cjs +0 -1
- package/language_models/base.d.cts +0 -1
- package/language_models/base.d.ts +0 -1
- package/language_models/base.js +0 -1
- package/language_models/chat_models.cjs +0 -1
- package/language_models/chat_models.d.cts +0 -1
- package/language_models/chat_models.d.ts +0 -1
- package/language_models/chat_models.js +0 -1
- package/language_models/llms.cjs +0 -1
- package/language_models/llms.d.cts +0 -1
- package/language_models/llms.d.ts +0 -1
- package/language_models/llms.js +0 -1
- package/language_models/profile.cjs +0 -1
- package/language_models/profile.d.cts +0 -1
- package/language_models/profile.d.ts +0 -1
- package/language_models/profile.js +0 -1
- package/language_models/structured_output.cjs +0 -1
- package/language_models/structured_output.d.cts +0 -1
- package/language_models/structured_output.d.ts +0 -1
- package/language_models/structured_output.js +0 -1
- package/load/serializable.cjs +0 -1
- package/load/serializable.d.cts +0 -1
- package/load/serializable.d.ts +0 -1
- package/load/serializable.js +0 -1
- package/load.cjs +0 -1
- package/load.d.cts +0 -1
- package/load.d.ts +0 -1
- package/load.js +0 -1
- package/memory.cjs +0 -1
- package/memory.d.cts +0 -1
- package/memory.d.ts +0 -1
- package/memory.js +0 -1
- package/messages/tool.cjs +0 -1
- package/messages/tool.d.cts +0 -1
- package/messages/tool.d.ts +0 -1
- package/messages/tool.js +0 -1
- package/messages.cjs +0 -1
- package/messages.d.cts +0 -1
- package/messages.d.ts +0 -1
- package/messages.js +0 -1
- package/output_parsers/openai_functions.cjs +0 -1
- package/output_parsers/openai_functions.d.cts +0 -1
- package/output_parsers/openai_functions.d.ts +0 -1
- package/output_parsers/openai_functions.js +0 -1
- package/output_parsers/openai_tools.cjs +0 -1
- package/output_parsers/openai_tools.d.cts +0 -1
- package/output_parsers/openai_tools.d.ts +0 -1
- package/output_parsers/openai_tools.js +0 -1
- package/output_parsers.cjs +0 -1
- package/output_parsers.d.cts +0 -1
- package/output_parsers.d.ts +0 -1
- package/output_parsers.js +0 -1
- package/outputs.cjs +0 -1
- package/outputs.d.cts +0 -1
- package/outputs.d.ts +0 -1
- package/outputs.js +0 -1
- package/prompt_values.cjs +0 -1
- package/prompt_values.d.cts +0 -1
- package/prompt_values.d.ts +0 -1
- package/prompt_values.js +0 -1
- package/prompts.cjs +0 -1
- package/prompts.d.cts +0 -1
- package/prompts.d.ts +0 -1
- package/prompts.js +0 -1
- package/retrievers/document_compressors.cjs +0 -1
- package/retrievers/document_compressors.d.cts +0 -1
- package/retrievers/document_compressors.d.ts +0 -1
- package/retrievers/document_compressors.js +0 -1
- package/retrievers.cjs +0 -1
- package/retrievers.d.cts +0 -1
- package/retrievers.d.ts +0 -1
- package/retrievers.js +0 -1
- package/runnables/graph.cjs +0 -1
- package/runnables/graph.d.cts +0 -1
- package/runnables/graph.d.ts +0 -1
- package/runnables/graph.js +0 -1
- package/runnables.cjs +0 -1
- package/runnables.d.cts +0 -1
- package/runnables.d.ts +0 -1
- package/runnables.js +0 -1
- package/singletons.cjs +0 -1
- package/singletons.d.cts +0 -1
- package/singletons.d.ts +0 -1
- package/singletons.js +0 -1
- package/stores.cjs +0 -1
- package/stores.d.cts +0 -1
- package/stores.d.ts +0 -1
- package/stores.js +0 -1
- package/structured_query.cjs +0 -1
- package/structured_query.d.cts +0 -1
- package/structured_query.d.ts +0 -1
- package/structured_query.js +0 -1
- package/tools.cjs +0 -1
- package/tools.d.cts +0 -1
- package/tools.d.ts +0 -1
- package/tools.js +0 -1
- package/tracers/base.cjs +0 -1
- package/tracers/base.d.cts +0 -1
- package/tracers/base.d.ts +0 -1
- package/tracers/base.js +0 -1
- package/tracers/console.cjs +0 -1
- package/tracers/console.d.cts +0 -1
- package/tracers/console.d.ts +0 -1
- package/tracers/console.js +0 -1
- package/tracers/log_stream.cjs +0 -1
- package/tracers/log_stream.d.cts +0 -1
- package/tracers/log_stream.d.ts +0 -1
- package/tracers/log_stream.js +0 -1
- package/tracers/run_collector.cjs +0 -1
- package/tracers/run_collector.d.cts +0 -1
- package/tracers/run_collector.d.ts +0 -1
- package/tracers/run_collector.js +0 -1
- package/tracers/tracer_langchain.cjs +0 -1
- package/tracers/tracer_langchain.d.cts +0 -1
- package/tracers/tracer_langchain.d.ts +0 -1
- package/tracers/tracer_langchain.js +0 -1
- package/types/stream.cjs +0 -1
- package/types/stream.d.cts +0 -1
- package/types/stream.d.ts +0 -1
- package/types/stream.js +0 -1
- package/utils/async_caller.cjs +0 -1
- package/utils/async_caller.d.cts +0 -1
- package/utils/async_caller.d.ts +0 -1
- package/utils/async_caller.js +0 -1
- package/utils/chunk_array.cjs +0 -1
- package/utils/chunk_array.d.cts +0 -1
- package/utils/chunk_array.d.ts +0 -1
- package/utils/chunk_array.js +0 -1
- package/utils/context.cjs +0 -1
- package/utils/context.d.cts +0 -1
- package/utils/context.d.ts +0 -1
- package/utils/context.js +0 -1
- package/utils/env.cjs +0 -1
- package/utils/env.d.cts +0 -1
- package/utils/env.d.ts +0 -1
- package/utils/env.js +0 -1
- package/utils/event_source_parse.cjs +0 -1
- package/utils/event_source_parse.d.cts +0 -1
- package/utils/event_source_parse.d.ts +0 -1
- package/utils/event_source_parse.js +0 -1
- package/utils/format.cjs +0 -1
- package/utils/format.d.cts +0 -1
- package/utils/format.d.ts +0 -1
- package/utils/format.js +0 -1
- package/utils/function_calling.cjs +0 -1
- package/utils/function_calling.d.cts +0 -1
- package/utils/function_calling.d.ts +0 -1
- package/utils/function_calling.js +0 -1
- package/utils/hash.cjs +0 -1
- package/utils/hash.d.cts +0 -1
- package/utils/hash.d.ts +0 -1
- package/utils/hash.js +0 -1
- package/utils/json_patch.cjs +0 -1
- package/utils/json_patch.d.cts +0 -1
- package/utils/json_patch.d.ts +0 -1
- package/utils/json_patch.js +0 -1
- package/utils/json_schema.cjs +0 -1
- package/utils/json_schema.d.cts +0 -1
- package/utils/json_schema.d.ts +0 -1
- package/utils/json_schema.js +0 -1
- package/utils/math.cjs +0 -1
- package/utils/math.d.cts +0 -1
- package/utils/math.d.ts +0 -1
- package/utils/math.js +0 -1
- package/utils/ssrf.cjs +0 -1
- package/utils/ssrf.d.cts +0 -1
- package/utils/ssrf.d.ts +0 -1
- package/utils/ssrf.js +0 -1
- package/utils/standard_schema.cjs +0 -1
- package/utils/standard_schema.d.cts +0 -1
- package/utils/standard_schema.d.ts +0 -1
- package/utils/standard_schema.js +0 -1
- package/utils/stream.cjs +0 -1
- package/utils/stream.d.cts +0 -1
- package/utils/stream.d.ts +0 -1
- package/utils/stream.js +0 -1
- package/utils/testing.cjs +0 -1
- package/utils/testing.d.cts +0 -1
- package/utils/testing.d.ts +0 -1
- package/utils/testing.js +0 -1
- package/utils/tiktoken.cjs +0 -1
- package/utils/tiktoken.d.cts +0 -1
- package/utils/tiktoken.d.ts +0 -1
- package/utils/tiktoken.js +0 -1
- package/utils/types.cjs +0 -1
- package/utils/types.d.cts +0 -1
- package/utils/types.d.ts +0 -1
- package/utils/types.js +0 -1
- package/vectorstores.cjs +0 -1
- package/vectorstores.d.cts +0 -1
- package/vectorstores.d.ts +0 -1
- package/vectorstores.js +0 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { AIMessage } from "../messages/ai.js";
|
|
3
|
+
//#region src/language_models/stream.ts
|
|
4
|
+
/**
|
|
5
|
+
* Typed stream classes for chat model streaming.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
var stream_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
ChatModelStream: () => ChatModelStream,
|
|
11
|
+
ReasoningContentStream: () => ReasoningContentStream,
|
|
12
|
+
TextContentStream: () => TextContentStream,
|
|
13
|
+
ToolCallsStream: () => ToolCallsStream,
|
|
14
|
+
UsageMetadataStream: () => UsageMetadataStream
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* A buffer that caches emitted events for replay.
|
|
18
|
+
*
|
|
19
|
+
* Multiple consumers can independently iterate the same buffer —
|
|
20
|
+
* each gets its own cursor. Events are never consumed or removed.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
var ReplayBuffer = class {
|
|
25
|
+
events = [];
|
|
26
|
+
finished = false;
|
|
27
|
+
waiters = [];
|
|
28
|
+
error = null;
|
|
29
|
+
push(event) {
|
|
30
|
+
this.events.push(event);
|
|
31
|
+
const toWake = this.waiters.splice(0);
|
|
32
|
+
for (const waiter of toWake) waiter();
|
|
33
|
+
}
|
|
34
|
+
finish() {
|
|
35
|
+
this.finished = true;
|
|
36
|
+
const toWake = this.waiters.splice(0);
|
|
37
|
+
for (const waiter of toWake) waiter();
|
|
38
|
+
}
|
|
39
|
+
setError(err) {
|
|
40
|
+
this.error = err;
|
|
41
|
+
this.finished = true;
|
|
42
|
+
const toWake = this.waiters.splice(0);
|
|
43
|
+
for (const waiter of toWake) waiter();
|
|
44
|
+
}
|
|
45
|
+
async *iterate() {
|
|
46
|
+
if (this.finished) {
|
|
47
|
+
if (this.error) throw this.error;
|
|
48
|
+
yield* this.events;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let cursor = 0;
|
|
52
|
+
while (true) {
|
|
53
|
+
while (cursor < this.events.length) {
|
|
54
|
+
yield this.events[cursor];
|
|
55
|
+
cursor++;
|
|
56
|
+
}
|
|
57
|
+
if (this.finished) {
|
|
58
|
+
if (this.error) throw this.error;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await new Promise((resolve) => {
|
|
62
|
+
if (cursor < this.events.length || this.finished) {
|
|
63
|
+
resolve();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.waiters.push(resolve);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Apply a typed delta to an accumulated content block.
|
|
73
|
+
*
|
|
74
|
+
* - `text` → append text
|
|
75
|
+
* - `reasoning` → append reasoning
|
|
76
|
+
* - `tool_call_chunk` / `server_tool_call_chunk` → append args while
|
|
77
|
+
* preserving id/name from previous chunks when a later delta omits them
|
|
78
|
+
* - other block types → shallow merge
|
|
79
|
+
*
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
function applyDelta(block, delta) {
|
|
83
|
+
if (block.type !== delta.type) return { ...delta };
|
|
84
|
+
switch (delta.type) {
|
|
85
|
+
case "text": return {
|
|
86
|
+
...block,
|
|
87
|
+
...delta,
|
|
88
|
+
text: (block.text ?? "") + delta.text
|
|
89
|
+
};
|
|
90
|
+
case "reasoning": return {
|
|
91
|
+
...block,
|
|
92
|
+
...delta,
|
|
93
|
+
reasoning: (block.reasoning ?? "") + delta.reasoning
|
|
94
|
+
};
|
|
95
|
+
case "tool_call_chunk":
|
|
96
|
+
case "server_tool_call_chunk": {
|
|
97
|
+
const merged = {
|
|
98
|
+
...block,
|
|
99
|
+
...delta
|
|
100
|
+
};
|
|
101
|
+
if (delta.id == null && "id" in block && block.id != null) merged.id = block.id;
|
|
102
|
+
if (delta.name == null && "name" in block && block.name != null) merged.name = block.name;
|
|
103
|
+
merged.args = `${("args" in block ? block.args : "") ?? ""}${delta.args ?? ""}`;
|
|
104
|
+
return merged;
|
|
105
|
+
}
|
|
106
|
+
default: return {
|
|
107
|
+
...block,
|
|
108
|
+
...delta
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Typed stream for text content.
|
|
114
|
+
*
|
|
115
|
+
* - **Iterate**: yields incremental text deltas.
|
|
116
|
+
* - **Await**: resolves to the complete concatenated text.
|
|
117
|
+
* - **`.full`**: yields the running accumulated text after each delta.
|
|
118
|
+
*/
|
|
119
|
+
var TextContentStream = class {
|
|
120
|
+
/** @internal */
|
|
121
|
+
_buffer;
|
|
122
|
+
/** @internal */
|
|
123
|
+
constructor(buffer) {
|
|
124
|
+
this._buffer = buffer;
|
|
125
|
+
}
|
|
126
|
+
/** Yields the accumulated text so far after each delta. */
|
|
127
|
+
get full() {
|
|
128
|
+
const buffer = this._buffer;
|
|
129
|
+
return { async *[Symbol.asyncIterator]() {
|
|
130
|
+
let accumulated = "";
|
|
131
|
+
for await (const event of buffer.iterate()) if (event.type === "content-block-delta" && event.content.type === "text" && typeof event.content.text === "string") {
|
|
132
|
+
accumulated += event.content.text;
|
|
133
|
+
yield accumulated;
|
|
134
|
+
}
|
|
135
|
+
} };
|
|
136
|
+
}
|
|
137
|
+
/** Yields incremental text deltas. */
|
|
138
|
+
[Symbol.asyncIterator]() {
|
|
139
|
+
const buffer = this._buffer;
|
|
140
|
+
async function* gen() {
|
|
141
|
+
for await (const event of buffer.iterate()) if (event.type === "content-block-delta" && event.content.type === "text" && typeof event.content.text === "string") yield event.content.text;
|
|
142
|
+
}
|
|
143
|
+
return gen();
|
|
144
|
+
}
|
|
145
|
+
then(onfulfilled, onrejected) {
|
|
146
|
+
return (async () => {
|
|
147
|
+
let text = "";
|
|
148
|
+
for await (const delta of this) text += delta;
|
|
149
|
+
return text;
|
|
150
|
+
})().then(onfulfilled, onrejected);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Typed stream for tool calls.
|
|
155
|
+
*
|
|
156
|
+
* - **Iterate**: yields individual `ToolCall` objects as each completes.
|
|
157
|
+
* - **Await**: resolves to the full array.
|
|
158
|
+
* - **`.full`**: yields the accumulated array after each new tool call.
|
|
159
|
+
*/
|
|
160
|
+
var ToolCallsStream = class {
|
|
161
|
+
/** @internal */
|
|
162
|
+
_buffer;
|
|
163
|
+
/** @internal */
|
|
164
|
+
constructor(buffer) {
|
|
165
|
+
this._buffer = buffer;
|
|
166
|
+
}
|
|
167
|
+
get full() {
|
|
168
|
+
const buffer = this._buffer;
|
|
169
|
+
return { async *[Symbol.asyncIterator]() {
|
|
170
|
+
const calls = [];
|
|
171
|
+
for await (const event of buffer.iterate()) if (event.type === "content-block-finish" && event.content.type === "tool_call") {
|
|
172
|
+
calls.push(event.content);
|
|
173
|
+
yield [...calls];
|
|
174
|
+
}
|
|
175
|
+
} };
|
|
176
|
+
}
|
|
177
|
+
[Symbol.asyncIterator]() {
|
|
178
|
+
const buffer = this._buffer;
|
|
179
|
+
async function* gen() {
|
|
180
|
+
for await (const event of buffer.iterate()) if (event.type === "content-block-finish" && event.content.type === "tool_call") yield event.content;
|
|
181
|
+
}
|
|
182
|
+
return gen();
|
|
183
|
+
}
|
|
184
|
+
then(onfulfilled, onrejected) {
|
|
185
|
+
return (async () => {
|
|
186
|
+
const calls = [];
|
|
187
|
+
for await (const call of this) calls.push(call);
|
|
188
|
+
return calls;
|
|
189
|
+
})().then(onfulfilled, onrejected);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Typed stream for reasoning content (chain-of-thought).
|
|
194
|
+
* Same interface as {@link TextContentStream} but for reasoning blocks.
|
|
195
|
+
*/
|
|
196
|
+
var ReasoningContentStream = class {
|
|
197
|
+
/** @internal */
|
|
198
|
+
_buffer;
|
|
199
|
+
/** @internal */
|
|
200
|
+
constructor(buffer) {
|
|
201
|
+
this._buffer = buffer;
|
|
202
|
+
}
|
|
203
|
+
get full() {
|
|
204
|
+
const buffer = this._buffer;
|
|
205
|
+
return { async *[Symbol.asyncIterator]() {
|
|
206
|
+
let accumulated = "";
|
|
207
|
+
for await (const event of buffer.iterate()) if (event.type === "content-block-delta" && event.content.type === "reasoning" && typeof event.content.reasoning === "string") {
|
|
208
|
+
accumulated += event.content.reasoning;
|
|
209
|
+
yield accumulated;
|
|
210
|
+
}
|
|
211
|
+
} };
|
|
212
|
+
}
|
|
213
|
+
[Symbol.asyncIterator]() {
|
|
214
|
+
const buffer = this._buffer;
|
|
215
|
+
async function* gen() {
|
|
216
|
+
for await (const event of buffer.iterate()) if (event.type === "content-block-delta" && event.content.type === "reasoning" && typeof event.content.reasoning === "string") yield event.content.reasoning;
|
|
217
|
+
}
|
|
218
|
+
return gen();
|
|
219
|
+
}
|
|
220
|
+
then(onfulfilled, onrejected) {
|
|
221
|
+
return (async () => {
|
|
222
|
+
let text = "";
|
|
223
|
+
for await (const delta of this) text += delta;
|
|
224
|
+
return text;
|
|
225
|
+
})().then(onfulfilled, onrejected);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Typed stream for usage metadata.
|
|
230
|
+
*/
|
|
231
|
+
var UsageMetadataStream = class {
|
|
232
|
+
/** @internal */
|
|
233
|
+
_buffer;
|
|
234
|
+
/** @internal */
|
|
235
|
+
constructor(buffer) {
|
|
236
|
+
this._buffer = buffer;
|
|
237
|
+
}
|
|
238
|
+
[Symbol.asyncIterator]() {
|
|
239
|
+
const buffer = this._buffer;
|
|
240
|
+
async function* gen() {
|
|
241
|
+
for await (const event of buffer.iterate()) if (event.type === "usage") yield event.usage;
|
|
242
|
+
else if (event.type === "message-start" && event.usage) yield event.usage;
|
|
243
|
+
else if (event.type === "message-finish" && event.usage) yield event.usage;
|
|
244
|
+
}
|
|
245
|
+
return gen();
|
|
246
|
+
}
|
|
247
|
+
then(onfulfilled, onrejected) {
|
|
248
|
+
return (async () => {
|
|
249
|
+
let latest;
|
|
250
|
+
for await (const usage of this) latest = usage;
|
|
251
|
+
return latest;
|
|
252
|
+
})().then(onfulfilled, onrejected);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* The main stream object returned by chat model streaming.
|
|
257
|
+
*
|
|
258
|
+
* Implements `AsyncIterable<ChatModelStreamEvent>` for raw event access
|
|
259
|
+
* and `PromiseLike<AIMessage>` for simple `await` usage.
|
|
260
|
+
*/
|
|
261
|
+
var ChatModelStream = class {
|
|
262
|
+
/** @internal */
|
|
263
|
+
_buffer;
|
|
264
|
+
/** @internal */
|
|
265
|
+
constructor(source) {
|
|
266
|
+
this._buffer = new ReplayBuffer();
|
|
267
|
+
this._consume(source);
|
|
268
|
+
}
|
|
269
|
+
/** @internal */
|
|
270
|
+
async _consume(source) {
|
|
271
|
+
try {
|
|
272
|
+
for await (const event of source) this._buffer.push(event);
|
|
273
|
+
this._buffer.finish();
|
|
274
|
+
} catch (err) {
|
|
275
|
+
this._buffer.setError(err instanceof Error ? err : new Error(String(err)));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
[Symbol.asyncIterator]() {
|
|
279
|
+
return this._buffer.iterate();
|
|
280
|
+
}
|
|
281
|
+
get text() {
|
|
282
|
+
return new TextContentStream(this._buffer);
|
|
283
|
+
}
|
|
284
|
+
get toolCalls() {
|
|
285
|
+
return new ToolCallsStream(this._buffer);
|
|
286
|
+
}
|
|
287
|
+
get reasoning() {
|
|
288
|
+
return new ReasoningContentStream(this._buffer);
|
|
289
|
+
}
|
|
290
|
+
get usage() {
|
|
291
|
+
return new UsageMetadataStream(this._buffer);
|
|
292
|
+
}
|
|
293
|
+
get output() {
|
|
294
|
+
return { then: (onf, onr) => this._assembleMessage().then(onf, onr) };
|
|
295
|
+
}
|
|
296
|
+
then(onfulfilled, onrejected) {
|
|
297
|
+
return this._assembleMessage().then(onfulfilled, onrejected);
|
|
298
|
+
}
|
|
299
|
+
/** @internal */
|
|
300
|
+
async _assembleMessage() {
|
|
301
|
+
const contentBlocks = [];
|
|
302
|
+
let id;
|
|
303
|
+
let usage;
|
|
304
|
+
let responseMetadata = {};
|
|
305
|
+
let finishReason;
|
|
306
|
+
for await (const event of this._buffer.iterate()) switch (event.type) {
|
|
307
|
+
case "message-start":
|
|
308
|
+
id = event.id ?? id;
|
|
309
|
+
if (event.usage) usage = event.usage;
|
|
310
|
+
break;
|
|
311
|
+
case "content-block-start":
|
|
312
|
+
contentBlocks[event.index] = event.content;
|
|
313
|
+
break;
|
|
314
|
+
case "content-block-delta": {
|
|
315
|
+
const current = contentBlocks[event.index];
|
|
316
|
+
if (current) contentBlocks[event.index] = applyDelta(current, event.content);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
case "content-block-finish":
|
|
320
|
+
contentBlocks[event.index] = event.content;
|
|
321
|
+
break;
|
|
322
|
+
case "usage":
|
|
323
|
+
usage = event.usage;
|
|
324
|
+
break;
|
|
325
|
+
case "message-finish":
|
|
326
|
+
finishReason = event.reason;
|
|
327
|
+
if (event.usage) usage = event.usage;
|
|
328
|
+
if (event.responseMetadata) responseMetadata = {
|
|
329
|
+
...responseMetadata,
|
|
330
|
+
...event.responseMetadata
|
|
331
|
+
};
|
|
332
|
+
break;
|
|
333
|
+
default: break;
|
|
334
|
+
}
|
|
335
|
+
const filteredBlocks = contentBlocks.filter((b) => b != null);
|
|
336
|
+
return new AIMessage({
|
|
337
|
+
id,
|
|
338
|
+
content: filteredBlocks,
|
|
339
|
+
usage_metadata: usage,
|
|
340
|
+
response_metadata: {
|
|
341
|
+
...responseMetadata,
|
|
342
|
+
...finishReason ? { finish_reason: finishReason } : {},
|
|
343
|
+
output_version: "v1"
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
//#endregion
|
|
349
|
+
export { ChatModelStream, ReasoningContentStream, TextContentStream, ToolCallsStream, UsageMetadataStream, stream_exports };
|
|
350
|
+
|
|
351
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","names":[],"sources":["../../src/language_models/stream.ts"],"sourcesContent":["/**\n * Typed stream classes for chat model streaming.\n *\n * @module\n */\n\nimport { AIMessage } from \"../messages/ai.js\";\nimport type { ContentBlock } from \"../messages/content/index.js\";\nimport type { UsageMetadata } from \"../messages/metadata.js\";\nimport type { ChatModelStreamEvent } from \"./event.js\";\n\n// ─── Replay Buffer ──────────────────────────────────────────────\n\n/**\n * A buffer that caches emitted events for replay.\n *\n * Multiple consumers can independently iterate the same buffer —\n * each gets its own cursor. Events are never consumed or removed.\n *\n * @internal\n */\nclass ReplayBuffer {\n private events: ChatModelStreamEvent[] = [];\n private finished = false;\n private waiters: Array<() => void> = [];\n private error: Error | null = null;\n\n push(event: ChatModelStreamEvent): void {\n this.events.push(event);\n const toWake = this.waiters.splice(0);\n for (const waiter of toWake) {\n waiter();\n }\n }\n\n finish(): void {\n this.finished = true;\n const toWake = this.waiters.splice(0);\n for (const waiter of toWake) {\n waiter();\n }\n }\n\n setError(err: Error): void {\n this.error = err;\n this.finished = true;\n const toWake = this.waiters.splice(0);\n for (const waiter of toWake) {\n waiter();\n }\n }\n\n async *iterate(): AsyncGenerator<ChatModelStreamEvent> {\n if (this.finished) {\n if (this.error) throw this.error;\n yield* this.events;\n return;\n }\n\n let cursor = 0;\n while (true) {\n while (cursor < this.events.length) {\n yield this.events[cursor]!;\n cursor++;\n }\n if (this.finished) {\n if (this.error) throw this.error;\n return;\n }\n await new Promise<void>((resolve) => {\n if (cursor < this.events.length || this.finished) {\n resolve();\n return;\n }\n this.waiters.push(resolve);\n });\n }\n }\n}\n\n// ─── Accumulator ────────────────────────────────────────────────\n\n/**\n * Apply a typed delta to an accumulated content block.\n *\n * - `text` → append text\n * - `reasoning` → append reasoning\n * - `tool_call_chunk` / `server_tool_call_chunk` → append args while\n * preserving id/name from previous chunks when a later delta omits them\n * - other block types → shallow merge\n *\n * @internal\n */\nfunction applyDelta(block: ContentBlock, delta: ContentBlock): ContentBlock {\n if (block.type !== delta.type) {\n return { ...delta };\n }\n\n switch (delta.type) {\n case \"text\":\n return {\n ...block,\n ...delta,\n text: ((block as { text?: string }).text ?? \"\") + delta.text,\n };\n case \"reasoning\":\n return {\n ...block,\n ...delta,\n reasoning:\n ((block as { reasoning?: string }).reasoning ?? \"\") + delta.reasoning,\n };\n case \"tool_call_chunk\":\n case \"server_tool_call_chunk\": {\n const merged = { ...block, ...delta } as Record<string, unknown>;\n if (delta.id == null && \"id\" in block && block.id != null) {\n merged.id = block.id;\n }\n if (delta.name == null && \"name\" in block && block.name != null) {\n merged.name = block.name;\n }\n merged.args = `${(\"args\" in block ? block.args : \"\") ?? \"\"}${delta.args ?? \"\"}`;\n return merged as unknown as ContentBlock;\n }\n default:\n return { ...block, ...delta };\n }\n}\n\n// ─── Sub-Stream: Text ───────────────────────────────────────────\n\n/**\n * Typed stream for text content.\n *\n * - **Iterate**: yields incremental text deltas.\n * - **Await**: resolves to the complete concatenated text.\n * - **`.full`**: yields the running accumulated text after each delta.\n */\nexport class TextContentStream\n implements AsyncIterable<string>, PromiseLike<string>\n{\n /** @internal */\n private _buffer: ReplayBuffer;\n\n /** @internal */\n constructor(buffer: ReplayBuffer) {\n this._buffer = buffer;\n }\n\n /** Yields the accumulated text so far after each delta. */\n get full(): AsyncIterable<string> {\n const buffer = this._buffer;\n return {\n async *[Symbol.asyncIterator]() {\n let accumulated = \"\";\n for await (const event of buffer.iterate()) {\n if (\n event.type === \"content-block-delta\" &&\n event.content.type === \"text\" &&\n typeof event.content.text === \"string\"\n ) {\n accumulated += event.content.text;\n yield accumulated;\n }\n }\n },\n };\n }\n\n /** Yields incremental text deltas. */\n [Symbol.asyncIterator](): AsyncIterator<string> {\n const buffer = this._buffer;\n async function* gen() {\n for await (const event of buffer.iterate()) {\n if (\n event.type === \"content-block-delta\" &&\n event.content.type === \"text\" &&\n typeof event.content.text === \"string\"\n ) {\n yield event.content.text;\n }\n }\n }\n return gen();\n }\n\n then<TResult1 = string, TResult2 = never>(\n onfulfilled?: ((value: string) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): PromiseLike<TResult1 | TResult2> {\n const promise = (async () => {\n let text = \"\";\n for await (const delta of this) {\n text += delta;\n }\n return text;\n })();\n return promise.then(onfulfilled, onrejected);\n }\n}\n\n// ─── Sub-Stream: Tool Calls ─────────────────────────────────────\n\n/**\n * Typed stream for tool calls.\n *\n * - **Iterate**: yields individual `ToolCall` objects as each completes.\n * - **Await**: resolves to the full array.\n * - **`.full`**: yields the accumulated array after each new tool call.\n */\nexport class ToolCallsStream\n implements\n AsyncIterable<ContentBlock.Tools.ToolCall>,\n PromiseLike<Array<ContentBlock.Tools.ToolCall>>\n{\n /** @internal */\n private _buffer: ReplayBuffer;\n\n /** @internal */\n constructor(buffer: ReplayBuffer) {\n this._buffer = buffer;\n }\n\n get full(): AsyncIterable<Array<ContentBlock.Tools.ToolCall>> {\n const buffer = this._buffer;\n return {\n async *[Symbol.asyncIterator]() {\n const calls: Array<ContentBlock.Tools.ToolCall> = [];\n for await (const event of buffer.iterate()) {\n if (\n event.type === \"content-block-finish\" &&\n event.content.type === \"tool_call\"\n ) {\n calls.push(event.content as ContentBlock.Tools.ToolCall);\n yield [...calls];\n }\n }\n },\n };\n }\n\n [Symbol.asyncIterator](): AsyncIterator<ContentBlock.Tools.ToolCall> {\n const buffer = this._buffer;\n async function* gen() {\n for await (const event of buffer.iterate()) {\n if (\n event.type === \"content-block-finish\" &&\n event.content.type === \"tool_call\"\n ) {\n yield event.content as ContentBlock.Tools.ToolCall;\n }\n }\n }\n return gen();\n }\n\n then<TResult1 = Array<ContentBlock.Tools.ToolCall>, TResult2 = never>(\n onfulfilled?:\n | ((\n value: Array<ContentBlock.Tools.ToolCall>\n ) => TResult1 | PromiseLike<TResult1>)\n | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): PromiseLike<TResult1 | TResult2> {\n const promise = (async () => {\n const calls: Array<ContentBlock.Tools.ToolCall> = [];\n for await (const call of this) {\n calls.push(call);\n }\n return calls;\n })();\n return promise.then(onfulfilled, onrejected);\n }\n}\n\n// ─── Sub-Stream: Reasoning ──────────────────────────────────────\n\n/**\n * Typed stream for reasoning content (chain-of-thought).\n * Same interface as {@link TextContentStream} but for reasoning blocks.\n */\nexport class ReasoningContentStream\n implements AsyncIterable<string>, PromiseLike<string>\n{\n /** @internal */\n private _buffer: ReplayBuffer;\n\n /** @internal */\n constructor(buffer: ReplayBuffer) {\n this._buffer = buffer;\n }\n\n get full(): AsyncIterable<string> {\n const buffer = this._buffer;\n return {\n async *[Symbol.asyncIterator]() {\n let accumulated = \"\";\n for await (const event of buffer.iterate()) {\n if (\n event.type === \"content-block-delta\" &&\n event.content.type === \"reasoning\" &&\n typeof event.content.reasoning === \"string\"\n ) {\n accumulated += event.content.reasoning;\n yield accumulated;\n }\n }\n },\n };\n }\n\n [Symbol.asyncIterator](): AsyncIterator<string> {\n const buffer = this._buffer;\n async function* gen() {\n for await (const event of buffer.iterate()) {\n if (\n event.type === \"content-block-delta\" &&\n event.content.type === \"reasoning\" &&\n typeof event.content.reasoning === \"string\"\n ) {\n yield event.content.reasoning;\n }\n }\n }\n return gen();\n }\n\n then<TResult1 = string, TResult2 = never>(\n onfulfilled?: ((value: string) => TResult1 | PromiseLike<TResult1>) | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): PromiseLike<TResult1 | TResult2> {\n const promise = (async () => {\n let text = \"\";\n for await (const delta of this) {\n text += delta;\n }\n return text;\n })();\n return promise.then(onfulfilled, onrejected);\n }\n}\n\n// ─── Sub-Stream: Usage ──────────────────────────────────────────\n\n/**\n * Typed stream for usage metadata.\n */\nexport class UsageMetadataStream\n implements\n AsyncIterable<UsageMetadata>,\n PromiseLike<UsageMetadata | undefined>\n{\n /** @internal */\n private _buffer: ReplayBuffer;\n\n /** @internal */\n constructor(buffer: ReplayBuffer) {\n this._buffer = buffer;\n }\n\n [Symbol.asyncIterator](): AsyncIterator<UsageMetadata> {\n const buffer = this._buffer;\n async function* gen() {\n for await (const event of buffer.iterate()) {\n if (event.type === \"usage\") {\n yield event.usage;\n } else if (event.type === \"message-start\" && event.usage) {\n yield event.usage;\n } else if (event.type === \"message-finish\" && event.usage) {\n yield event.usage;\n }\n }\n }\n return gen();\n }\n\n then<TResult1 = UsageMetadata | undefined, TResult2 = never>(\n onfulfilled?:\n | ((value: UsageMetadata | undefined) => TResult1 | PromiseLike<TResult1>)\n | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): PromiseLike<TResult1 | TResult2> {\n const promise = (async () => {\n let latest: UsageMetadata | undefined;\n for await (const usage of this) {\n latest = usage;\n }\n return latest;\n })();\n return promise.then(onfulfilled, onrejected);\n }\n}\n\n// ─── ChatModelStream ────────────────────────────────────────────\n\n/**\n * The main stream object returned by chat model streaming.\n *\n * Implements `AsyncIterable<ChatModelStreamEvent>` for raw event access\n * and `PromiseLike<AIMessage>` for simple `await` usage.\n */\nexport class ChatModelStream\n implements AsyncIterable<ChatModelStreamEvent>, PromiseLike<AIMessage>\n{\n /** @internal */\n private _buffer: ReplayBuffer;\n\n /** @internal */\n constructor(source: AsyncIterable<ChatModelStreamEvent>) {\n this._buffer = new ReplayBuffer();\n this._consume(source);\n }\n\n /** @internal */\n private async _consume(\n source: AsyncIterable<ChatModelStreamEvent>\n ): Promise<void> {\n try {\n for await (const event of source) {\n this._buffer.push(event);\n }\n this._buffer.finish();\n } catch (err) {\n this._buffer.setError(\n err instanceof Error ? err : new Error(String(err))\n );\n }\n }\n\n [Symbol.asyncIterator](): AsyncIterator<ChatModelStreamEvent> {\n return this._buffer.iterate();\n }\n\n get text(): TextContentStream {\n return new TextContentStream(this._buffer);\n }\n\n get toolCalls(): ToolCallsStream {\n return new ToolCallsStream(this._buffer);\n }\n\n get reasoning(): ReasoningContentStream {\n return new ReasoningContentStream(this._buffer);\n }\n\n get usage(): UsageMetadataStream {\n return new UsageMetadataStream(this._buffer);\n }\n\n get output(): PromiseLike<AIMessage> {\n return { then: (onf, onr) => this._assembleMessage().then(onf, onr) };\n }\n\n then<TResult1 = AIMessage, TResult2 = never>(\n onfulfilled?:\n | ((value: AIMessage) => TResult1 | PromiseLike<TResult1>)\n | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null\n ): PromiseLike<TResult1 | TResult2> {\n return this._assembleMessage().then(onfulfilled, onrejected);\n }\n\n /** @internal */\n private async _assembleMessage(): Promise<AIMessage> {\n const contentBlocks: Array<ContentBlock | undefined> = [];\n let id: string | undefined;\n let usage: UsageMetadata | undefined;\n let responseMetadata: Record<string, unknown> = {};\n let finishReason: string | undefined;\n\n for await (const event of this._buffer.iterate()) {\n switch (event.type) {\n case \"message-start\":\n id = event.id ?? id;\n if (event.usage) usage = event.usage;\n break;\n\n case \"content-block-start\":\n contentBlocks[event.index] = event.content;\n break;\n\n case \"content-block-delta\": {\n const current = contentBlocks[event.index];\n if (current) {\n contentBlocks[event.index] = applyDelta(current, event.content);\n }\n break;\n }\n\n case \"content-block-finish\":\n contentBlocks[event.index] = event.content;\n break;\n\n case \"usage\":\n usage = event.usage;\n break;\n\n case \"message-finish\":\n finishReason = event.reason;\n if (event.usage) usage = event.usage;\n if (event.responseMetadata) {\n responseMetadata = {\n ...responseMetadata,\n ...event.responseMetadata,\n };\n }\n break;\n\n default:\n break;\n }\n }\n\n const filteredBlocks = contentBlocks.filter(\n (b): b is ContentBlock => b != null\n );\n\n return new AIMessage({\n id,\n content: filteredBlocks,\n usage_metadata: usage,\n response_metadata: {\n ...responseMetadata,\n ...(finishReason ? { finish_reason: finishReason } : {}),\n output_version: \"v1\" as const,\n },\n });\n }\n}\n"],"mappings":"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"}
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -37,7 +37,10 @@ const require_utils_json_patch = require("../utils/json_patch.cjs");
|
|
|
37
37
|
const require_output_parsers_index = require("../output_parsers/index.cjs");
|
|
38
38
|
const require_utils_types_index = require("../utils/types/index.cjs");
|
|
39
39
|
const require_language_models_structured_output = require("../language_models/structured_output.cjs");
|
|
40
|
+
const require_language_models_stream = require("../language_models/stream.cjs");
|
|
41
|
+
const require_language_models_compat = require("../language_models/compat.cjs");
|
|
40
42
|
const require_language_models_chat_models = require("../language_models/chat_models.cjs");
|
|
43
|
+
const require_language_models_event = require("../language_models/event.cjs");
|
|
41
44
|
const require_language_models_llms = require("../language_models/llms.cjs");
|
|
42
45
|
const require_language_models_profile = require("../language_models/profile.cjs");
|
|
43
46
|
const require_memory = require("../memory.cjs");
|
|
@@ -79,8 +82,11 @@ var import_map_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
79
82
|
indexing: () => require_indexing_index.indexing_exports,
|
|
80
83
|
language_models__base: () => require_language_models_base.base_exports,
|
|
81
84
|
language_models__chat_models: () => require_language_models_chat_models.chat_models_exports,
|
|
85
|
+
language_models__compat: () => require_language_models_compat.compat_exports,
|
|
86
|
+
language_models__event: () => require_language_models_event.event_exports,
|
|
82
87
|
language_models__llms: () => require_language_models_llms.llms_exports,
|
|
83
88
|
language_models__profile: () => require_language_models_profile.profile_exports,
|
|
89
|
+
language_models__stream: () => require_language_models_stream.stream_exports,
|
|
84
90
|
language_models__structured_output: () => require_language_models_structured_output.structured_output_exports,
|
|
85
91
|
load__serializable: () => require_load_serializable.serializable_exports,
|
|
86
92
|
memory: () => require_memory.memory_exports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_map.cjs","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as agents from \"../agents.js\";\nexport * as caches from \"../caches/index.js\";\nexport * as callbacks__base from \"../callbacks/base.js\";\nexport * as callbacks__manager from \"../callbacks/manager.js\";\nexport * as callbacks__promises from \"../callbacks/promises.js\";\nexport * as chat_history from \"../chat_history.js\";\nexport * as document_loaders__base from \"../document_loaders/base.js\";\nexport * as document_loaders__langsmith from \"../document_loaders/langsmith.js\";\nexport * as documents from \"../documents/index.js\";\nexport * as embeddings from \"../embeddings.js\";\nexport * as errors from \"../errors/index.js\";\nexport * as example_selectors from \"../example_selectors/index.js\";\nexport * as index from \"../index.js\";\nexport * as indexing from \"../indexing/index.js\";\nexport * as language_models__base from \"../language_models/base.js\";\nexport * as language_models__chat_models from \"../language_models/chat_models.js\";\nexport * as language_models__llms from \"../language_models/llms.js\";\nexport * as language_models__profile from \"../language_models/profile.js\";\nexport * as language_models__structured_output from \"../language_models/structured_output.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as memory from \"../memory.js\";\nexport * as messages from \"../messages/index.js\";\nexport * as messages__tool from \"../messages/tool.js\";\nexport * as output_parsers from \"../output_parsers/index.js\";\nexport * as output_parsers__openai_functions from \"../output_parsers/openai_functions/index.js\";\nexport * as output_parsers__openai_tools from \"../output_parsers/openai_tools/index.js\";\nexport * as outputs from \"../outputs.js\";\nexport * as prompt_values from \"../prompt_values.js\";\nexport * as prompts from \"../prompts/index.js\";\nexport * as retrievers__document_compressors from \"../retrievers/document_compressors/index.js\";\nexport * as retrievers from \"../retrievers/index.js\";\nexport * as runnables__graph from \"../runnables/graph.js\";\nexport * as runnables from \"../runnables/index.js\";\nexport * as singletons from \"../singletons/index.js\";\nexport * as stores from \"../stores.js\";\nexport * as structured_query from \"../structured_query/index.js\";\nexport * as testing from \"../testing/index.js\";\nexport * as tools from \"../tools/index.js\";\nexport * as tracers__base from \"../tracers/base.js\";\nexport * as tracers__console from \"../tracers/console.js\";\nexport * as tracers__log_stream from \"../tracers/log_stream.js\";\nexport * as tracers__run_collector from \"../tracers/run_collector.js\";\nexport * as tracers__tracer_langchain from \"../tracers/tracer_langchain.js\";\nexport * as types__stream from \"../types/stream.js\";\nexport * as utils__async_caller from \"../utils/async_caller.js\";\nexport * as utils__chunk_array from \"../utils/chunk_array.js\";\nexport * as utils__context from \"../utils/context.js\";\nexport * as utils__env from \"../utils/env.js\";\nexport * as utils__event_source_parse from \"../utils/event_source_parse.js\";\nexport * as utils__format from \"../utils/format.js\";\nexport * as utils__function_calling from \"../utils/function_calling.js\";\nexport * as utils__hash from \"../utils/hash.js\";\nexport * as utils__json_patch from \"../utils/json_patch.js\";\nexport * as utils__json_schema from \"../utils/json_schema.js\";\nexport * as utils__math from \"../utils/math.js\";\nexport * as utils__ssrf from \"../utils/ssrf.js\";\nexport * as utils__standard_schema from \"../utils/standard_schema.js\";\nexport * as utils__stream from \"../utils/stream.js\";\nexport * as utils__testing from \"../utils/testing/index.js\";\nexport * as utils__tiktoken from \"../utils/tiktoken.js\";\nexport * as utils__types from \"../utils/types/index.js\";\nexport * as vectorstores from \"../vectorstores.js\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"import_map.cjs","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as agents from \"../agents.js\";\nexport * as caches from \"../caches/index.js\";\nexport * as callbacks__base from \"../callbacks/base.js\";\nexport * as callbacks__manager from \"../callbacks/manager.js\";\nexport * as callbacks__promises from \"../callbacks/promises.js\";\nexport * as chat_history from \"../chat_history.js\";\nexport * as document_loaders__base from \"../document_loaders/base.js\";\nexport * as document_loaders__langsmith from \"../document_loaders/langsmith.js\";\nexport * as documents from \"../documents/index.js\";\nexport * as embeddings from \"../embeddings.js\";\nexport * as errors from \"../errors/index.js\";\nexport * as example_selectors from \"../example_selectors/index.js\";\nexport * as index from \"../index.js\";\nexport * as indexing from \"../indexing/index.js\";\nexport * as language_models__base from \"../language_models/base.js\";\nexport * as language_models__chat_models from \"../language_models/chat_models.js\";\nexport * as language_models__compat from \"../language_models/compat.js\";\nexport * as language_models__event from \"../language_models/event.js\";\nexport * as language_models__llms from \"../language_models/llms.js\";\nexport * as language_models__profile from \"../language_models/profile.js\";\nexport * as language_models__stream from \"../language_models/stream.js\";\nexport * as language_models__structured_output from \"../language_models/structured_output.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as memory from \"../memory.js\";\nexport * as messages from \"../messages/index.js\";\nexport * as messages__tool from \"../messages/tool.js\";\nexport * as output_parsers from \"../output_parsers/index.js\";\nexport * as output_parsers__openai_functions from \"../output_parsers/openai_functions/index.js\";\nexport * as output_parsers__openai_tools from \"../output_parsers/openai_tools/index.js\";\nexport * as outputs from \"../outputs.js\";\nexport * as prompt_values from \"../prompt_values.js\";\nexport * as prompts from \"../prompts/index.js\";\nexport * as retrievers__document_compressors from \"../retrievers/document_compressors/index.js\";\nexport * as retrievers from \"../retrievers/index.js\";\nexport * as runnables__graph from \"../runnables/graph.js\";\nexport * as runnables from \"../runnables/index.js\";\nexport * as singletons from \"../singletons/index.js\";\nexport * as stores from \"../stores.js\";\nexport * as structured_query from \"../structured_query/index.js\";\nexport * as testing from \"../testing/index.js\";\nexport * as tools from \"../tools/index.js\";\nexport * as tracers__base from \"../tracers/base.js\";\nexport * as tracers__console from \"../tracers/console.js\";\nexport * as tracers__log_stream from \"../tracers/log_stream.js\";\nexport * as tracers__run_collector from \"../tracers/run_collector.js\";\nexport * as tracers__tracer_langchain from \"../tracers/tracer_langchain.js\";\nexport * as types__stream from \"../types/stream.js\";\nexport * as utils__async_caller from \"../utils/async_caller.js\";\nexport * as utils__chunk_array from \"../utils/chunk_array.js\";\nexport * as utils__context from \"../utils/context.js\";\nexport * as utils__env from \"../utils/env.js\";\nexport * as utils__event_source_parse from \"../utils/event_source_parse.js\";\nexport * as utils__format from \"../utils/format.js\";\nexport * as utils__function_calling from \"../utils/function_calling.js\";\nexport * as utils__hash from \"../utils/hash.js\";\nexport * as utils__json_patch from \"../utils/json_patch.js\";\nexport * as utils__json_schema from \"../utils/json_schema.js\";\nexport * as utils__math from \"../utils/math.js\";\nexport * as utils__ssrf from \"../utils/ssrf.js\";\nexport * as utils__standard_schema from \"../utils/standard_schema.js\";\nexport * as utils__stream from \"../utils/stream.js\";\nexport * as utils__testing from \"../utils/testing/index.js\";\nexport * as utils__tiktoken from \"../utils/tiktoken.js\";\nexport * as utils__types from \"../utils/types/index.js\";\nexport * as vectorstores from \"../vectorstores.js\";\n"],"mappings":""}
|
package/dist/load/import_map.js
CHANGED
|
@@ -37,7 +37,10 @@ import { json_patch_exports } from "../utils/json_patch.js";
|
|
|
37
37
|
import { output_parsers_exports } from "../output_parsers/index.js";
|
|
38
38
|
import { types_exports } from "../utils/types/index.js";
|
|
39
39
|
import { structured_output_exports } from "../language_models/structured_output.js";
|
|
40
|
+
import { stream_exports as stream_exports$1 } from "../language_models/stream.js";
|
|
41
|
+
import { compat_exports } from "../language_models/compat.js";
|
|
40
42
|
import { chat_models_exports } from "../language_models/chat_models.js";
|
|
43
|
+
import { event_exports } from "../language_models/event.js";
|
|
41
44
|
import { llms_exports } from "../language_models/llms.js";
|
|
42
45
|
import { profile_exports } from "../language_models/profile.js";
|
|
43
46
|
import { memory_exports } from "../memory.js";
|
|
@@ -51,7 +54,7 @@ import { structured_query_exports } from "../structured_query/index.js";
|
|
|
51
54
|
import { testing_exports } from "../testing/index.js";
|
|
52
55
|
import { tools_exports } from "../tools/index.js";
|
|
53
56
|
import { run_collector_exports } from "../tracers/run_collector.js";
|
|
54
|
-
import { stream_exports as stream_exports$
|
|
57
|
+
import { stream_exports as stream_exports$2 } from "../types/stream.js";
|
|
55
58
|
import { chunk_array_exports } from "../utils/chunk_array.js";
|
|
56
59
|
import { context_exports } from "../utils/context.js";
|
|
57
60
|
import { event_source_parse_exports } from "../utils/event_source_parse.js";
|
|
@@ -79,8 +82,11 @@ var import_map_exports = /* @__PURE__ */ __exportAll({
|
|
|
79
82
|
indexing: () => indexing_exports,
|
|
80
83
|
language_models__base: () => base_exports$3,
|
|
81
84
|
language_models__chat_models: () => chat_models_exports,
|
|
85
|
+
language_models__compat: () => compat_exports,
|
|
86
|
+
language_models__event: () => event_exports,
|
|
82
87
|
language_models__llms: () => llms_exports,
|
|
83
88
|
language_models__profile: () => profile_exports,
|
|
89
|
+
language_models__stream: () => stream_exports$1,
|
|
84
90
|
language_models__structured_output: () => structured_output_exports,
|
|
85
91
|
load__serializable: () => serializable_exports,
|
|
86
92
|
memory: () => memory_exports,
|
|
@@ -106,7 +112,7 @@ var import_map_exports = /* @__PURE__ */ __exportAll({
|
|
|
106
112
|
tracers__log_stream: () => log_stream_exports,
|
|
107
113
|
tracers__run_collector: () => run_collector_exports,
|
|
108
114
|
tracers__tracer_langchain: () => tracer_langchain_exports,
|
|
109
|
-
types__stream: () => stream_exports$
|
|
115
|
+
types__stream: () => stream_exports$2,
|
|
110
116
|
utils__async_caller: () => async_caller_exports,
|
|
111
117
|
utils__chunk_array: () => chunk_array_exports,
|
|
112
118
|
utils__context: () => context_exports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_map.js","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as agents from \"../agents.js\";\nexport * as caches from \"../caches/index.js\";\nexport * as callbacks__base from \"../callbacks/base.js\";\nexport * as callbacks__manager from \"../callbacks/manager.js\";\nexport * as callbacks__promises from \"../callbacks/promises.js\";\nexport * as chat_history from \"../chat_history.js\";\nexport * as document_loaders__base from \"../document_loaders/base.js\";\nexport * as document_loaders__langsmith from \"../document_loaders/langsmith.js\";\nexport * as documents from \"../documents/index.js\";\nexport * as embeddings from \"../embeddings.js\";\nexport * as errors from \"../errors/index.js\";\nexport * as example_selectors from \"../example_selectors/index.js\";\nexport * as index from \"../index.js\";\nexport * as indexing from \"../indexing/index.js\";\nexport * as language_models__base from \"../language_models/base.js\";\nexport * as language_models__chat_models from \"../language_models/chat_models.js\";\nexport * as language_models__llms from \"../language_models/llms.js\";\nexport * as language_models__profile from \"../language_models/profile.js\";\nexport * as language_models__structured_output from \"../language_models/structured_output.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as memory from \"../memory.js\";\nexport * as messages from \"../messages/index.js\";\nexport * as messages__tool from \"../messages/tool.js\";\nexport * as output_parsers from \"../output_parsers/index.js\";\nexport * as output_parsers__openai_functions from \"../output_parsers/openai_functions/index.js\";\nexport * as output_parsers__openai_tools from \"../output_parsers/openai_tools/index.js\";\nexport * as outputs from \"../outputs.js\";\nexport * as prompt_values from \"../prompt_values.js\";\nexport * as prompts from \"../prompts/index.js\";\nexport * as retrievers__document_compressors from \"../retrievers/document_compressors/index.js\";\nexport * as retrievers from \"../retrievers/index.js\";\nexport * as runnables__graph from \"../runnables/graph.js\";\nexport * as runnables from \"../runnables/index.js\";\nexport * as singletons from \"../singletons/index.js\";\nexport * as stores from \"../stores.js\";\nexport * as structured_query from \"../structured_query/index.js\";\nexport * as testing from \"../testing/index.js\";\nexport * as tools from \"../tools/index.js\";\nexport * as tracers__base from \"../tracers/base.js\";\nexport * as tracers__console from \"../tracers/console.js\";\nexport * as tracers__log_stream from \"../tracers/log_stream.js\";\nexport * as tracers__run_collector from \"../tracers/run_collector.js\";\nexport * as tracers__tracer_langchain from \"../tracers/tracer_langchain.js\";\nexport * as types__stream from \"../types/stream.js\";\nexport * as utils__async_caller from \"../utils/async_caller.js\";\nexport * as utils__chunk_array from \"../utils/chunk_array.js\";\nexport * as utils__context from \"../utils/context.js\";\nexport * as utils__env from \"../utils/env.js\";\nexport * as utils__event_source_parse from \"../utils/event_source_parse.js\";\nexport * as utils__format from \"../utils/format.js\";\nexport * as utils__function_calling from \"../utils/function_calling.js\";\nexport * as utils__hash from \"../utils/hash.js\";\nexport * as utils__json_patch from \"../utils/json_patch.js\";\nexport * as utils__json_schema from \"../utils/json_schema.js\";\nexport * as utils__math from \"../utils/math.js\";\nexport * as utils__ssrf from \"../utils/ssrf.js\";\nexport * as utils__standard_schema from \"../utils/standard_schema.js\";\nexport * as utils__stream from \"../utils/stream.js\";\nexport * as utils__testing from \"../utils/testing/index.js\";\nexport * as utils__tiktoken from \"../utils/tiktoken.js\";\nexport * as utils__types from \"../utils/types/index.js\";\nexport * as vectorstores from \"../vectorstores.js\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"import_map.js","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as agents from \"../agents.js\";\nexport * as caches from \"../caches/index.js\";\nexport * as callbacks__base from \"../callbacks/base.js\";\nexport * as callbacks__manager from \"../callbacks/manager.js\";\nexport * as callbacks__promises from \"../callbacks/promises.js\";\nexport * as chat_history from \"../chat_history.js\";\nexport * as document_loaders__base from \"../document_loaders/base.js\";\nexport * as document_loaders__langsmith from \"../document_loaders/langsmith.js\";\nexport * as documents from \"../documents/index.js\";\nexport * as embeddings from \"../embeddings.js\";\nexport * as errors from \"../errors/index.js\";\nexport * as example_selectors from \"../example_selectors/index.js\";\nexport * as index from \"../index.js\";\nexport * as indexing from \"../indexing/index.js\";\nexport * as language_models__base from \"../language_models/base.js\";\nexport * as language_models__chat_models from \"../language_models/chat_models.js\";\nexport * as language_models__compat from \"../language_models/compat.js\";\nexport * as language_models__event from \"../language_models/event.js\";\nexport * as language_models__llms from \"../language_models/llms.js\";\nexport * as language_models__profile from \"../language_models/profile.js\";\nexport * as language_models__stream from \"../language_models/stream.js\";\nexport * as language_models__structured_output from \"../language_models/structured_output.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as memory from \"../memory.js\";\nexport * as messages from \"../messages/index.js\";\nexport * as messages__tool from \"../messages/tool.js\";\nexport * as output_parsers from \"../output_parsers/index.js\";\nexport * as output_parsers__openai_functions from \"../output_parsers/openai_functions/index.js\";\nexport * as output_parsers__openai_tools from \"../output_parsers/openai_tools/index.js\";\nexport * as outputs from \"../outputs.js\";\nexport * as prompt_values from \"../prompt_values.js\";\nexport * as prompts from \"../prompts/index.js\";\nexport * as retrievers__document_compressors from \"../retrievers/document_compressors/index.js\";\nexport * as retrievers from \"../retrievers/index.js\";\nexport * as runnables__graph from \"../runnables/graph.js\";\nexport * as runnables from \"../runnables/index.js\";\nexport * as singletons from \"../singletons/index.js\";\nexport * as stores from \"../stores.js\";\nexport * as structured_query from \"../structured_query/index.js\";\nexport * as testing from \"../testing/index.js\";\nexport * as tools from \"../tools/index.js\";\nexport * as tracers__base from \"../tracers/base.js\";\nexport * as tracers__console from \"../tracers/console.js\";\nexport * as tracers__log_stream from \"../tracers/log_stream.js\";\nexport * as tracers__run_collector from \"../tracers/run_collector.js\";\nexport * as tracers__tracer_langchain from \"../tracers/tracer_langchain.js\";\nexport * as types__stream from \"../types/stream.js\";\nexport * as utils__async_caller from \"../utils/async_caller.js\";\nexport * as utils__chunk_array from \"../utils/chunk_array.js\";\nexport * as utils__context from \"../utils/context.js\";\nexport * as utils__env from \"../utils/env.js\";\nexport * as utils__event_source_parse from \"../utils/event_source_parse.js\";\nexport * as utils__format from \"../utils/format.js\";\nexport * as utils__function_calling from \"../utils/function_calling.js\";\nexport * as utils__hash from \"../utils/hash.js\";\nexport * as utils__json_patch from \"../utils/json_patch.js\";\nexport * as utils__json_schema from \"../utils/json_schema.js\";\nexport * as utils__math from \"../utils/math.js\";\nexport * as utils__ssrf from \"../utils/ssrf.js\";\nexport * as utils__standard_schema from \"../utils/standard_schema.js\";\nexport * as utils__stream from \"../utils/stream.js\";\nexport * as utils__testing from \"../utils/testing/index.js\";\nexport * as utils__tiktoken from \"../utils/tiktoken.js\";\nexport * as utils__types from \"../utils/types/index.js\";\nexport * as vectorstores from \"../vectorstores.js\";\n"],"mappings":""}
|
package/dist/load/map_keys.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let decamelize = require("decamelize");
|
|
3
|
-
decamelize = require_runtime.__toESM(decamelize);
|
|
3
|
+
decamelize = require_runtime.__toESM(decamelize, 1);
|
|
4
4
|
let camelcase = require("camelcase");
|
|
5
|
-
camelcase = require_runtime.__toESM(camelcase);
|
|
5
|
+
camelcase = require_runtime.__toESM(camelcase, 1);
|
|
6
6
|
//#region src/load/map_keys.ts
|
|
7
7
|
function keyToJson(key, map) {
|
|
8
8
|
return map?.[key] || (0, decamelize.default)(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nimport { type DeepPartial } from \"../../types/type-utils.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport type PartialContentBlock<T extends ContentBlock = ContentBlock> = {\n readonly type: T[\"type\"];\n} & DeepPartial<Exclude<T, \"type\">>;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;AAkBA,MAAa,oBAAoB;CAC/B;CACA;CACA,GAAGA,cAAAA;CACH,GAAGC,mBAAAA;CACJ"}
|
|
@@ -2,9 +2,13 @@ import { BaseContentBlock } from "./base.cjs";
|
|
|
2
2
|
import { Tools } from "./tools.cjs";
|
|
3
3
|
import { Multimodal } from "./multimodal.cjs";
|
|
4
4
|
import { Data } from "./data.cjs";
|
|
5
|
+
import { DeepPartial } from "../../types/type-utils.cjs";
|
|
5
6
|
|
|
6
7
|
//#region src/messages/content/index.d.ts
|
|
7
8
|
interface ContentBlock extends BaseContentBlock {}
|
|
9
|
+
type PartialContentBlock<T extends ContentBlock = ContentBlock> = {
|
|
10
|
+
readonly type: T["type"];
|
|
11
|
+
} & DeepPartial<Exclude<T, "type">>;
|
|
8
12
|
declare const KNOWN_BLOCK_TYPES: string[];
|
|
9
13
|
declare namespace ContentBlock {
|
|
10
14
|
/**
|
|
@@ -113,5 +117,5 @@ declare namespace ContentBlock {
|
|
|
113
117
|
export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
|
|
114
118
|
}
|
|
115
119
|
//#endregion
|
|
116
|
-
export { ContentBlock, KNOWN_BLOCK_TYPES };
|
|
120
|
+
export { ContentBlock, KNOWN_BLOCK_TYPES, PartialContentBlock };
|
|
117
121
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":";;;;;;;UAYiB,YAAA,SAAqB,gBAAA;AAAA,KAE1B,mBAAA,WAA8B,YAAA,GAAe,YAAA;EAAA,SAC9C,IAAA,EAAM,CAAA;AAAA,IACb,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA,cAEX,iBAAA;AAAA,kBAQY,YAAA;EAZb;;;EAAA,iBAgBO,QAAA;IAhBsC;;;IAAA,SAoB5C,IAAA;IAlBT;;;IAsBA,MAAA;IAxBsC;;;IA4BtC,GAAA;IA1BA;;;;;IAgCA,KAAA;IAzBH;;;;AAGD;IA4BI,UAAA;IA5BiC;;;;;IAkCjC,QAAA;IA8De;;;IA1Df,SAAA;EAAA;EAuEO;;;;;;EAAA,iBA9DQ,IAAA,SAAa,YAAA;IAsEP;;;IAAA,SAlEZ,IAAA;IAvCT;;;IA2CA,IAAA;IArBA;;;IAyBA,KAAA;IARS;;;IAYT,WAAA,GAAc,KAAA,CAAM,QAAA,GAAW,gBAAA;EAAA;EAAX;;;EAAA,iBAML,SAAA,SAAkB,YAAA;IAIxB;;;IAAA,SAAA,IAAA;IAuBT;;;;;;IAhBA,SAAA;IA4BO;;;IAxBP,KAAA;EAAA;EA0BO;;;;;;;EAAA,iBAhBQ,WAAA,gBAEA,MAAA,gBAAsB,MAAA,uBAC7B,YAAA;IAoBK;;;IAhBb,IAAA;;;;IAIA,KAAA,EAAO,MAAA;EAAA;EAAA,SAGA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,YAEG,QAAA,GACR,IAAA,GACA,SAAA,GACA,WAAA,GACA,KAAA,CAAM,QAAA,GACN,UAAA,CAAW,QAAA;AAAA"}
|
|
@@ -2,9 +2,13 @@ import { BaseContentBlock } from "./base.js";
|
|
|
2
2
|
import { Tools } from "./tools.js";
|
|
3
3
|
import { Multimodal } from "./multimodal.js";
|
|
4
4
|
import { Data } from "./data.js";
|
|
5
|
+
import { DeepPartial } from "../../types/type-utils.js";
|
|
5
6
|
|
|
6
7
|
//#region src/messages/content/index.d.ts
|
|
7
8
|
interface ContentBlock extends BaseContentBlock {}
|
|
9
|
+
type PartialContentBlock<T extends ContentBlock = ContentBlock> = {
|
|
10
|
+
readonly type: T["type"];
|
|
11
|
+
} & DeepPartial<Exclude<T, "type">>;
|
|
8
12
|
declare const KNOWN_BLOCK_TYPES: string[];
|
|
9
13
|
declare namespace ContentBlock {
|
|
10
14
|
/**
|
|
@@ -113,5 +117,5 @@ declare namespace ContentBlock {
|
|
|
113
117
|
export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
|
|
114
118
|
}
|
|
115
119
|
//#endregion
|
|
116
|
-
export { ContentBlock, KNOWN_BLOCK_TYPES };
|
|
120
|
+
export { ContentBlock, KNOWN_BLOCK_TYPES, PartialContentBlock };
|
|
117
121
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":";;;;;;;UAYiB,YAAA,SAAqB,gBAAA;AAAA,KAE1B,mBAAA,WAA8B,YAAA,GAAe,YAAA;EAAA,SAC9C,IAAA,EAAM,CAAA;AAAA,IACb,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA,cAEX,iBAAA;AAAA,kBAQY,YAAA;EAZb;;;EAAA,iBAgBO,QAAA;IAhBsC;;;IAAA,SAoB5C,IAAA;IAlBT;;;IAsBA,MAAA;IAxBsC;;;IA4BtC,GAAA;IA1BA;;;;;IAgCA,KAAA;IAzBH;;;;AAGD;IA4BI,UAAA;IA5BiC;;;;;IAkCjC,QAAA;IA8De;;;IA1Df,SAAA;EAAA;EAuEO;;;;;;EAAA,iBA9DQ,IAAA,SAAa,YAAA;IAsEP;;;IAAA,SAlEZ,IAAA;IAvCT;;;IA2CA,IAAA;IArBA;;;IAyBA,KAAA;IARS;;;IAYT,WAAA,GAAc,KAAA,CAAM,QAAA,GAAW,gBAAA;EAAA;EAAX;;;EAAA,iBAML,SAAA,SAAkB,YAAA;IAIxB;;;IAAA,SAAA,IAAA;IAuBT;;;;;;IAhBA,SAAA;IA4BO;;;IAxBP,KAAA;EAAA;EA0BO;;;;;;;EAAA,iBAhBQ,WAAA,gBAEA,MAAA,gBAAsB,MAAA,uBAC7B,YAAA;IAoBK;;;IAhBb,IAAA;;;;IAIA,KAAA,EAAO,MAAA;EAAA;EAAA,SAGA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,YAEG,QAAA,GACR,IAAA,GACA,SAAA,GACA,WAAA,GACA,KAAA,CAAM,QAAA,GACN,UAAA,CAAW,QAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nimport { type DeepPartial } from \"../../types/type-utils.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport type PartialContentBlock<T extends ContentBlock = ContentBlock> = {\n readonly type: T[\"type\"];\n} & DeepPartial<Exclude<T, \"type\">>;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;AAkBA,MAAa,oBAAoB;CAC/B;CACA;CACA,GAAGA;CACH,GAAGC;CACJ"}
|