@langchain/core 0.1.27 → 0.1.29-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat_history.cjs +33 -0
- package/dist/chat_history.d.ts +32 -1
- package/dist/chat_history.js +33 -0
- package/dist/language_models/chat_models.d.ts +1 -1
- package/dist/load/index.cjs +3 -3
- package/dist/load/index.d.ts +5 -5
- package/dist/load/index.js +3 -3
- package/dist/tracers/log_stream.d.ts +1 -1
- package/dist/tracers/tracer_langchain.cjs +5 -38
- package/dist/tracers/tracer_langchain.d.ts +11 -15
- package/dist/tracers/tracer_langchain.js +5 -38
- package/package.json +1 -1
package/dist/chat_history.cjs
CHANGED
|
@@ -15,6 +15,13 @@ exports.BaseChatMessageHistory = BaseChatMessageHistory;
|
|
|
15
15
|
* histories should extend this class.
|
|
16
16
|
*/
|
|
17
17
|
class BaseListChatMessageHistory extends serializable_js_1.Serializable {
|
|
18
|
+
/**
|
|
19
|
+
* This is a convenience method for adding a human message string to the store.
|
|
20
|
+
* Please note that this is a convenience method. Code should favor the
|
|
21
|
+
* bulk addMessages interface instead to save on round-trips to the underlying
|
|
22
|
+
* persistence layer.
|
|
23
|
+
* This method may be deprecated in a future release.
|
|
24
|
+
*/
|
|
18
25
|
addUserMessage(message) {
|
|
19
26
|
return this.addMessage(new index_js_1.HumanMessage(message));
|
|
20
27
|
}
|
|
@@ -22,8 +29,34 @@ class BaseListChatMessageHistory extends serializable_js_1.Serializable {
|
|
|
22
29
|
addAIChatMessage(message) {
|
|
23
30
|
return this.addMessage(new index_js_1.AIMessage(message));
|
|
24
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* This is a convenience method for adding an AI message string to the store.
|
|
34
|
+
* Please note that this is a convenience method. Code should favor the bulk
|
|
35
|
+
* addMessages interface instead to save on round-trips to the underlying
|
|
36
|
+
* persistence layer.
|
|
37
|
+
* This method may be deprecated in a future release.
|
|
38
|
+
*/
|
|
25
39
|
addAIMessage(message) {
|
|
26
40
|
return this.addMessage(new index_js_1.AIMessage(message));
|
|
27
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Add a list of messages.
|
|
44
|
+
*
|
|
45
|
+
* Implementations should override this method to handle bulk addition of messages
|
|
46
|
+
* in an efficient manner to avoid unnecessary round-trips to the underlying store.
|
|
47
|
+
*
|
|
48
|
+
* @param messages - A list of BaseMessage objects to store.
|
|
49
|
+
*/
|
|
50
|
+
async addMessages(messages) {
|
|
51
|
+
for (const message of messages) {
|
|
52
|
+
await this.addMessage(message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Remove all messages from the store.
|
|
57
|
+
*/
|
|
58
|
+
clear() {
|
|
59
|
+
throw new Error("Not implemented.");
|
|
60
|
+
}
|
|
28
61
|
}
|
|
29
62
|
exports.BaseListChatMessageHistory = BaseListChatMessageHistory;
|
package/dist/chat_history.d.ts
CHANGED
|
@@ -16,10 +16,41 @@ export declare abstract class BaseChatMessageHistory extends Serializable {
|
|
|
16
16
|
* histories should extend this class.
|
|
17
17
|
*/
|
|
18
18
|
export declare abstract class BaseListChatMessageHistory extends Serializable {
|
|
19
|
+
/** Returns a list of messages stored in the store. */
|
|
20
|
+
abstract getMessages(): Promise<BaseMessage[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Add a message object to the store.
|
|
23
|
+
*/
|
|
19
24
|
abstract addMessage(message: BaseMessage): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* This is a convenience method for adding a human message string to the store.
|
|
27
|
+
* Please note that this is a convenience method. Code should favor the
|
|
28
|
+
* bulk addMessages interface instead to save on round-trips to the underlying
|
|
29
|
+
* persistence layer.
|
|
30
|
+
* This method may be deprecated in a future release.
|
|
31
|
+
*/
|
|
20
32
|
addUserMessage(message: string): Promise<void>;
|
|
21
33
|
/** @deprecated Use addAIMessage instead */
|
|
22
34
|
addAIChatMessage(message: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* This is a convenience method for adding an AI message string to the store.
|
|
37
|
+
* Please note that this is a convenience method. Code should favor the bulk
|
|
38
|
+
* addMessages interface instead to save on round-trips to the underlying
|
|
39
|
+
* persistence layer.
|
|
40
|
+
* This method may be deprecated in a future release.
|
|
41
|
+
*/
|
|
23
42
|
addAIMessage(message: string): Promise<void>;
|
|
24
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Add a list of messages.
|
|
45
|
+
*
|
|
46
|
+
* Implementations should override this method to handle bulk addition of messages
|
|
47
|
+
* in an efficient manner to avoid unnecessary round-trips to the underlying store.
|
|
48
|
+
*
|
|
49
|
+
* @param messages - A list of BaseMessage objects to store.
|
|
50
|
+
*/
|
|
51
|
+
addMessages(messages: BaseMessage[]): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Remove all messages from the store.
|
|
54
|
+
*/
|
|
55
|
+
clear(): Promise<void>;
|
|
25
56
|
}
|
package/dist/chat_history.js
CHANGED
|
@@ -11,6 +11,13 @@ export class BaseChatMessageHistory extends Serializable {
|
|
|
11
11
|
* histories should extend this class.
|
|
12
12
|
*/
|
|
13
13
|
export class BaseListChatMessageHistory extends Serializable {
|
|
14
|
+
/**
|
|
15
|
+
* This is a convenience method for adding a human message string to the store.
|
|
16
|
+
* Please note that this is a convenience method. Code should favor the
|
|
17
|
+
* bulk addMessages interface instead to save on round-trips to the underlying
|
|
18
|
+
* persistence layer.
|
|
19
|
+
* This method may be deprecated in a future release.
|
|
20
|
+
*/
|
|
14
21
|
addUserMessage(message) {
|
|
15
22
|
return this.addMessage(new HumanMessage(message));
|
|
16
23
|
}
|
|
@@ -18,7 +25,33 @@ export class BaseListChatMessageHistory extends Serializable {
|
|
|
18
25
|
addAIChatMessage(message) {
|
|
19
26
|
return this.addMessage(new AIMessage(message));
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* This is a convenience method for adding an AI message string to the store.
|
|
30
|
+
* Please note that this is a convenience method. Code should favor the bulk
|
|
31
|
+
* addMessages interface instead to save on round-trips to the underlying
|
|
32
|
+
* persistence layer.
|
|
33
|
+
* This method may be deprecated in a future release.
|
|
34
|
+
*/
|
|
21
35
|
addAIMessage(message) {
|
|
22
36
|
return this.addMessage(new AIMessage(message));
|
|
23
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Add a list of messages.
|
|
40
|
+
*
|
|
41
|
+
* Implementations should override this method to handle bulk addition of messages
|
|
42
|
+
* in an efficient manner to avoid unnecessary round-trips to the underlying store.
|
|
43
|
+
*
|
|
44
|
+
* @param messages - A list of BaseMessage objects to store.
|
|
45
|
+
*/
|
|
46
|
+
async addMessages(messages) {
|
|
47
|
+
for (const message of messages) {
|
|
48
|
+
await this.addMessage(message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Remove all messages from the store.
|
|
53
|
+
*/
|
|
54
|
+
clear() {
|
|
55
|
+
throw new Error("Not implemented.");
|
|
56
|
+
}
|
|
24
57
|
}
|
|
@@ -48,7 +48,7 @@ export declare abstract class BaseChatModel<CallOptions extends BaseChatModelCal
|
|
|
48
48
|
ParsedCallOptions: Omit<CallOptions, keyof RunnableConfig & "timeout">;
|
|
49
49
|
lc_namespace: string[];
|
|
50
50
|
constructor(fields: BaseChatModelParams);
|
|
51
|
-
|
|
51
|
+
_combineLLMOutput?(...llmOutputs: LLMResult["llmOutput"][]): LLMResult["llmOutput"];
|
|
52
52
|
protected _separateRunnableConfigFromCallOptions(options?: Partial<CallOptions>): [RunnableConfig, this["ParsedCallOptions"]];
|
|
53
53
|
/**
|
|
54
54
|
* Invokes the chat model with a single input.
|
package/dist/load/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ function combineAliasesAndInvert(constructor) {
|
|
|
42
42
|
}, {});
|
|
43
43
|
}
|
|
44
44
|
async function reviver(value) {
|
|
45
|
-
const { optionalImportsMap, optionalImportEntrypoints, importMap, secretsMap, path = ["$"], } = this;
|
|
45
|
+
const { optionalImportsMap = {}, optionalImportEntrypoints = [], importMap = {}, secretsMap = {}, path = ["$"], } = this;
|
|
46
46
|
const pathStr = path.join(".");
|
|
47
47
|
if (typeof value === "object" &&
|
|
48
48
|
value !== null &&
|
|
@@ -182,8 +182,8 @@ async function reviver(value) {
|
|
|
182
182
|
}
|
|
183
183
|
return value;
|
|
184
184
|
}
|
|
185
|
-
async function load(text,
|
|
185
|
+
async function load(text, mappings) {
|
|
186
186
|
const json = JSON.parse(text);
|
|
187
|
-
return reviver.call({
|
|
187
|
+
return reviver.call({ ...mappings }, json);
|
|
188
188
|
}
|
|
189
189
|
exports.load = load;
|
package/dist/load/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OptionalImportMap, SecretMap } from "./import_type.js";
|
|
2
|
-
export declare function load<T>(text: string,
|
|
3
|
-
secretsMap
|
|
4
|
-
optionalImportsMap
|
|
5
|
-
optionalImportEntrypoints
|
|
6
|
-
importMap
|
|
2
|
+
export declare function load<T>(text: string, mappings?: {
|
|
3
|
+
secretsMap?: SecretMap;
|
|
4
|
+
optionalImportsMap?: OptionalImportMap;
|
|
5
|
+
optionalImportEntrypoints?: string[];
|
|
6
|
+
importMap?: Record<string, unknown>;
|
|
7
7
|
}): Promise<T>;
|
package/dist/load/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function combineAliasesAndInvert(constructor) {
|
|
|
16
16
|
}, {});
|
|
17
17
|
}
|
|
18
18
|
async function reviver(value) {
|
|
19
|
-
const { optionalImportsMap, optionalImportEntrypoints, importMap, secretsMap, path = ["$"], } = this;
|
|
19
|
+
const { optionalImportsMap = {}, optionalImportEntrypoints = [], importMap = {}, secretsMap = {}, path = ["$"], } = this;
|
|
20
20
|
const pathStr = path.join(".");
|
|
21
21
|
if (typeof value === "object" &&
|
|
22
22
|
value !== null &&
|
|
@@ -156,7 +156,7 @@ async function reviver(value) {
|
|
|
156
156
|
}
|
|
157
157
|
return value;
|
|
158
158
|
}
|
|
159
|
-
export async function load(text,
|
|
159
|
+
export async function load(text, mappings) {
|
|
160
160
|
const json = JSON.parse(text);
|
|
161
|
-
return reviver.call({
|
|
161
|
+
return reviver.call({ ...mappings }, json);
|
|
162
162
|
}
|
|
@@ -101,7 +101,7 @@ export type StreamEventData = {
|
|
|
101
101
|
/**
|
|
102
102
|
* A streaming event.
|
|
103
103
|
*
|
|
104
|
-
* Schema of a streaming event which is produced from the
|
|
104
|
+
* Schema of a streaming event which is produced from the streamEvents method.
|
|
105
105
|
*/
|
|
106
106
|
export type StreamEvent = {
|
|
107
107
|
/**
|
|
@@ -52,55 +52,22 @@ class LangChainTracer extends base_js_1.BaseTracer {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
async persistRun(_run) { }
|
|
55
|
-
async
|
|
55
|
+
async onRunCreate(run) {
|
|
56
56
|
const persistedRun = await this._convertToCreate(run, this.exampleId);
|
|
57
57
|
await this.client.createRun(persistedRun);
|
|
58
58
|
}
|
|
59
|
-
async
|
|
59
|
+
async onRunUpdate(run) {
|
|
60
60
|
const runUpdate = {
|
|
61
61
|
end_time: run.end_time,
|
|
62
62
|
error: run.error,
|
|
63
63
|
outputs: run.outputs,
|
|
64
64
|
events: run.events,
|
|
65
65
|
inputs: run.inputs,
|
|
66
|
+
trace_id: run.trace_id,
|
|
67
|
+
dotted_order: run.dotted_order,
|
|
68
|
+
parent_run_id: run.parent_run_id,
|
|
66
69
|
};
|
|
67
70
|
await this.client.updateRun(run.id, runUpdate);
|
|
68
71
|
}
|
|
69
|
-
async onRetrieverStart(run) {
|
|
70
|
-
await this._persistRunSingle(run);
|
|
71
|
-
}
|
|
72
|
-
async onRetrieverEnd(run) {
|
|
73
|
-
await this._updateRunSingle(run);
|
|
74
|
-
}
|
|
75
|
-
async onRetrieverError(run) {
|
|
76
|
-
await this._updateRunSingle(run);
|
|
77
|
-
}
|
|
78
|
-
async onLLMStart(run) {
|
|
79
|
-
await this._persistRunSingle(run);
|
|
80
|
-
}
|
|
81
|
-
async onLLMEnd(run) {
|
|
82
|
-
await this._updateRunSingle(run);
|
|
83
|
-
}
|
|
84
|
-
async onLLMError(run) {
|
|
85
|
-
await this._updateRunSingle(run);
|
|
86
|
-
}
|
|
87
|
-
async onChainStart(run) {
|
|
88
|
-
await this._persistRunSingle(run);
|
|
89
|
-
}
|
|
90
|
-
async onChainEnd(run) {
|
|
91
|
-
await this._updateRunSingle(run);
|
|
92
|
-
}
|
|
93
|
-
async onChainError(run) {
|
|
94
|
-
await this._updateRunSingle(run);
|
|
95
|
-
}
|
|
96
|
-
async onToolStart(run) {
|
|
97
|
-
await this._persistRunSingle(run);
|
|
98
|
-
}
|
|
99
|
-
async onToolEnd(run) {
|
|
100
|
-
await this._updateRunSingle(run);
|
|
101
|
-
}
|
|
102
|
-
async onToolError(run) {
|
|
103
|
-
await this._updateRunSingle(run);
|
|
104
|
-
}
|
|
105
72
|
}
|
|
106
73
|
exports.LangChainTracer = LangChainTracer;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { Client } from "langsmith";
|
|
2
|
-
import { BaseRun, RunUpdate as BaseRunUpdate, KVMap } from "langsmith/schemas";
|
|
2
|
+
import { BaseRun, RunCreate, RunUpdate as BaseRunUpdate, KVMap } from "langsmith/schemas";
|
|
3
3
|
import { BaseTracer } from "./base.js";
|
|
4
4
|
import { BaseCallbackHandlerInput } from "../callbacks/base.js";
|
|
5
5
|
export interface Run extends BaseRun {
|
|
6
6
|
id: string;
|
|
7
7
|
child_runs: this[];
|
|
8
8
|
child_execution_order: number;
|
|
9
|
+
dotted_order?: string;
|
|
10
|
+
trace_id?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RunCreate2 extends RunCreate {
|
|
13
|
+
trace_id?: string;
|
|
14
|
+
dotted_order?: string;
|
|
9
15
|
}
|
|
10
16
|
export interface RunUpdate extends BaseRunUpdate {
|
|
11
17
|
events: BaseRun["events"];
|
|
12
18
|
inputs: KVMap;
|
|
19
|
+
trace_id?: string;
|
|
20
|
+
dotted_order?: string;
|
|
13
21
|
}
|
|
14
22
|
export interface LangChainTracerFields extends BaseCallbackHandlerInput {
|
|
15
23
|
exampleId?: string;
|
|
@@ -24,18 +32,6 @@ export declare class LangChainTracer extends BaseTracer implements LangChainTrac
|
|
|
24
32
|
constructor(fields?: LangChainTracerFields);
|
|
25
33
|
private _convertToCreate;
|
|
26
34
|
protected persistRun(_run: Run): Promise<void>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onRetrieverStart(run: Run): Promise<void>;
|
|
30
|
-
onRetrieverEnd(run: Run): Promise<void>;
|
|
31
|
-
onRetrieverError(run: Run): Promise<void>;
|
|
32
|
-
onLLMStart(run: Run): Promise<void>;
|
|
33
|
-
onLLMEnd(run: Run): Promise<void>;
|
|
34
|
-
onLLMError(run: Run): Promise<void>;
|
|
35
|
-
onChainStart(run: Run): Promise<void>;
|
|
36
|
-
onChainEnd(run: Run): Promise<void>;
|
|
37
|
-
onChainError(run: Run): Promise<void>;
|
|
38
|
-
onToolStart(run: Run): Promise<void>;
|
|
39
|
-
onToolEnd(run: Run): Promise<void>;
|
|
40
|
-
onToolError(run: Run): Promise<void>;
|
|
35
|
+
onRunCreate(run: Run): Promise<void>;
|
|
36
|
+
onRunUpdate(run: Run): Promise<void>;
|
|
41
37
|
}
|
|
@@ -49,54 +49,21 @@ export class LangChainTracer extends BaseTracer {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
async persistRun(_run) { }
|
|
52
|
-
async
|
|
52
|
+
async onRunCreate(run) {
|
|
53
53
|
const persistedRun = await this._convertToCreate(run, this.exampleId);
|
|
54
54
|
await this.client.createRun(persistedRun);
|
|
55
55
|
}
|
|
56
|
-
async
|
|
56
|
+
async onRunUpdate(run) {
|
|
57
57
|
const runUpdate = {
|
|
58
58
|
end_time: run.end_time,
|
|
59
59
|
error: run.error,
|
|
60
60
|
outputs: run.outputs,
|
|
61
61
|
events: run.events,
|
|
62
62
|
inputs: run.inputs,
|
|
63
|
+
trace_id: run.trace_id,
|
|
64
|
+
dotted_order: run.dotted_order,
|
|
65
|
+
parent_run_id: run.parent_run_id,
|
|
63
66
|
};
|
|
64
67
|
await this.client.updateRun(run.id, runUpdate);
|
|
65
68
|
}
|
|
66
|
-
async onRetrieverStart(run) {
|
|
67
|
-
await this._persistRunSingle(run);
|
|
68
|
-
}
|
|
69
|
-
async onRetrieverEnd(run) {
|
|
70
|
-
await this._updateRunSingle(run);
|
|
71
|
-
}
|
|
72
|
-
async onRetrieverError(run) {
|
|
73
|
-
await this._updateRunSingle(run);
|
|
74
|
-
}
|
|
75
|
-
async onLLMStart(run) {
|
|
76
|
-
await this._persistRunSingle(run);
|
|
77
|
-
}
|
|
78
|
-
async onLLMEnd(run) {
|
|
79
|
-
await this._updateRunSingle(run);
|
|
80
|
-
}
|
|
81
|
-
async onLLMError(run) {
|
|
82
|
-
await this._updateRunSingle(run);
|
|
83
|
-
}
|
|
84
|
-
async onChainStart(run) {
|
|
85
|
-
await this._persistRunSingle(run);
|
|
86
|
-
}
|
|
87
|
-
async onChainEnd(run) {
|
|
88
|
-
await this._updateRunSingle(run);
|
|
89
|
-
}
|
|
90
|
-
async onChainError(run) {
|
|
91
|
-
await this._updateRunSingle(run);
|
|
92
|
-
}
|
|
93
|
-
async onToolStart(run) {
|
|
94
|
-
await this._persistRunSingle(run);
|
|
95
|
-
}
|
|
96
|
-
async onToolEnd(run) {
|
|
97
|
-
await this._updateRunSingle(run);
|
|
98
|
-
}
|
|
99
|
-
async onToolError(run) {
|
|
100
|
-
await this._updateRunSingle(run);
|
|
101
|
-
}
|
|
102
69
|
}
|