@langchain/core 0.1.55-rc.0 → 0.1.56
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/agents.d.ts +1 -1
- package/dist/caches.d.ts +1 -1
- package/dist/language_models/chat_models.d.ts +14 -3
- package/dist/messages/ai.cjs +213 -0
- package/dist/messages/ai.d.ts +37 -0
- package/dist/messages/ai.js +207 -0
- package/dist/messages/base.cjs +212 -0
- package/dist/messages/base.d.ts +137 -0
- package/dist/messages/base.js +201 -0
- package/dist/messages/chat.cjs +71 -0
- package/dist/messages/chat.d.ts +28 -0
- package/dist/messages/chat.js +66 -0
- package/dist/messages/function.cjs +46 -0
- package/dist/messages/function.d.ts +24 -0
- package/dist/messages/function.js +41 -0
- package/dist/messages/human.cjs +36 -0
- package/dist/messages/human.d.ts +17 -0
- package/dist/messages/human.js +31 -0
- package/dist/messages/index.cjs +27 -633
- package/dist/messages/index.d.ts +8 -273
- package/dist/messages/index.js +10 -611
- package/dist/messages/system.cjs +36 -0
- package/dist/messages/system.d.ts +17 -0
- package/dist/messages/system.js +31 -0
- package/dist/messages/tool.cjs +101 -0
- package/dist/messages/tool.d.ts +101 -0
- package/dist/messages/tool.js +95 -0
- package/dist/messages/utils.cjs +172 -0
- package/dist/messages/utils.d.ts +31 -0
- package/dist/messages/utils.js +163 -0
- package/dist/output_parsers/json.cjs +6 -93
- package/dist/output_parsers/json.d.ts +2 -2
- package/dist/output_parsers/json.js +2 -88
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +79 -13
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +18 -0
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +75 -12
- package/dist/output_parsers/transform.cjs +7 -6
- package/dist/output_parsers/transform.d.ts +1 -1
- package/dist/output_parsers/transform.js +3 -2
- package/dist/utils/function_calling.cjs +18 -6
- package/dist/utils/function_calling.d.ts +2 -1
- package/dist/utils/function_calling.js +16 -5
- package/dist/utils/json.cjs +93 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +88 -0
- package/dist/utils/testing/index.cjs +3 -0
- package/dist/utils/testing/index.js +3 -0
- package/messages/tool.cjs +1 -0
- package/messages/tool.d.cts +1 -0
- package/messages/tool.d.ts +1 -0
- package/messages/tool.js +1 -0
- package/package.json +14 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageChunk, mergeContent, _mergeDicts, } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a chat message in a conversation.
|
|
4
|
+
*/
|
|
5
|
+
export class ChatMessage extends BaseMessage {
|
|
6
|
+
static lc_name() {
|
|
7
|
+
return "ChatMessage";
|
|
8
|
+
}
|
|
9
|
+
static _chatMessageClass() {
|
|
10
|
+
return ChatMessage;
|
|
11
|
+
}
|
|
12
|
+
constructor(fields, role) {
|
|
13
|
+
if (typeof fields === "string") {
|
|
14
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion
|
|
15
|
+
fields = { content: fields, role: role };
|
|
16
|
+
}
|
|
17
|
+
super(fields);
|
|
18
|
+
Object.defineProperty(this, "role", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
this.role = fields.role;
|
|
25
|
+
}
|
|
26
|
+
_getType() {
|
|
27
|
+
return "generic";
|
|
28
|
+
}
|
|
29
|
+
static isInstance(message) {
|
|
30
|
+
return message._getType() === "generic";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Represents a chunk of a chat message, which can be concatenated with
|
|
35
|
+
* other chat message chunks.
|
|
36
|
+
*/
|
|
37
|
+
export class ChatMessageChunk extends BaseMessageChunk {
|
|
38
|
+
static lc_name() {
|
|
39
|
+
return "ChatMessageChunk";
|
|
40
|
+
}
|
|
41
|
+
constructor(fields, role) {
|
|
42
|
+
if (typeof fields === "string") {
|
|
43
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion
|
|
44
|
+
fields = { content: fields, role: role };
|
|
45
|
+
}
|
|
46
|
+
super(fields);
|
|
47
|
+
Object.defineProperty(this, "role", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
this.role = fields.role;
|
|
54
|
+
}
|
|
55
|
+
_getType() {
|
|
56
|
+
return "generic";
|
|
57
|
+
}
|
|
58
|
+
concat(chunk) {
|
|
59
|
+
return new ChatMessageChunk({
|
|
60
|
+
content: mergeContent(this.content, chunk.content),
|
|
61
|
+
additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),
|
|
62
|
+
response_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata),
|
|
63
|
+
role: this.role,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionMessageChunk = exports.FunctionMessage = void 0;
|
|
4
|
+
const base_js_1 = require("./base.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a function message in a conversation.
|
|
7
|
+
*/
|
|
8
|
+
class FunctionMessage extends base_js_1.BaseMessage {
|
|
9
|
+
static lc_name() {
|
|
10
|
+
return "FunctionMessage";
|
|
11
|
+
}
|
|
12
|
+
constructor(fields,
|
|
13
|
+
/** @deprecated */
|
|
14
|
+
name) {
|
|
15
|
+
if (typeof fields === "string") {
|
|
16
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion
|
|
17
|
+
fields = { content: fields, name: name };
|
|
18
|
+
}
|
|
19
|
+
super(fields);
|
|
20
|
+
}
|
|
21
|
+
_getType() {
|
|
22
|
+
return "function";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.FunctionMessage = FunctionMessage;
|
|
26
|
+
/**
|
|
27
|
+
* Represents a chunk of a function message, which can be concatenated
|
|
28
|
+
* with other function message chunks.
|
|
29
|
+
*/
|
|
30
|
+
class FunctionMessageChunk extends base_js_1.BaseMessageChunk {
|
|
31
|
+
static lc_name() {
|
|
32
|
+
return "FunctionMessageChunk";
|
|
33
|
+
}
|
|
34
|
+
_getType() {
|
|
35
|
+
return "function";
|
|
36
|
+
}
|
|
37
|
+
concat(chunk) {
|
|
38
|
+
return new FunctionMessageChunk({
|
|
39
|
+
content: (0, base_js_1.mergeContent)(this.content, chunk.content),
|
|
40
|
+
additional_kwargs: (0, base_js_1._mergeDicts)(this.additional_kwargs, chunk.additional_kwargs),
|
|
41
|
+
response_metadata: (0, base_js_1._mergeDicts)(this.response_metadata, chunk.response_metadata),
|
|
42
|
+
name: this.name ?? "",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.FunctionMessageChunk = FunctionMessageChunk;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageChunk, type BaseMessageFields, type MessageType } from "./base.js";
|
|
2
|
+
export interface FunctionMessageFieldsWithName extends BaseMessageFields {
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Represents a function message in a conversation.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FunctionMessage extends BaseMessage {
|
|
9
|
+
static lc_name(): string;
|
|
10
|
+
constructor(fields: FunctionMessageFieldsWithName);
|
|
11
|
+
constructor(fields: string | BaseMessageFields,
|
|
12
|
+
/** @deprecated */
|
|
13
|
+
name: string);
|
|
14
|
+
_getType(): MessageType;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents a chunk of a function message, which can be concatenated
|
|
18
|
+
* with other function message chunks.
|
|
19
|
+
*/
|
|
20
|
+
export declare class FunctionMessageChunk extends BaseMessageChunk {
|
|
21
|
+
static lc_name(): string;
|
|
22
|
+
_getType(): MessageType;
|
|
23
|
+
concat(chunk: FunctionMessageChunk): FunctionMessageChunk;
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageChunk, mergeContent, _mergeDicts, } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a function message in a conversation.
|
|
4
|
+
*/
|
|
5
|
+
export class FunctionMessage extends BaseMessage {
|
|
6
|
+
static lc_name() {
|
|
7
|
+
return "FunctionMessage";
|
|
8
|
+
}
|
|
9
|
+
constructor(fields,
|
|
10
|
+
/** @deprecated */
|
|
11
|
+
name) {
|
|
12
|
+
if (typeof fields === "string") {
|
|
13
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion
|
|
14
|
+
fields = { content: fields, name: name };
|
|
15
|
+
}
|
|
16
|
+
super(fields);
|
|
17
|
+
}
|
|
18
|
+
_getType() {
|
|
19
|
+
return "function";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents a chunk of a function message, which can be concatenated
|
|
24
|
+
* with other function message chunks.
|
|
25
|
+
*/
|
|
26
|
+
export class FunctionMessageChunk extends BaseMessageChunk {
|
|
27
|
+
static lc_name() {
|
|
28
|
+
return "FunctionMessageChunk";
|
|
29
|
+
}
|
|
30
|
+
_getType() {
|
|
31
|
+
return "function";
|
|
32
|
+
}
|
|
33
|
+
concat(chunk) {
|
|
34
|
+
return new FunctionMessageChunk({
|
|
35
|
+
content: mergeContent(this.content, chunk.content),
|
|
36
|
+
additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),
|
|
37
|
+
response_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata),
|
|
38
|
+
name: this.name ?? "",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HumanMessageChunk = exports.HumanMessage = void 0;
|
|
4
|
+
const base_js_1 = require("./base.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a human message in a conversation.
|
|
7
|
+
*/
|
|
8
|
+
class HumanMessage extends base_js_1.BaseMessage {
|
|
9
|
+
static lc_name() {
|
|
10
|
+
return "HumanMessage";
|
|
11
|
+
}
|
|
12
|
+
_getType() {
|
|
13
|
+
return "human";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.HumanMessage = HumanMessage;
|
|
17
|
+
/**
|
|
18
|
+
* Represents a chunk of a human message, which can be concatenated with
|
|
19
|
+
* other human message chunks.
|
|
20
|
+
*/
|
|
21
|
+
class HumanMessageChunk extends base_js_1.BaseMessageChunk {
|
|
22
|
+
static lc_name() {
|
|
23
|
+
return "HumanMessageChunk";
|
|
24
|
+
}
|
|
25
|
+
_getType() {
|
|
26
|
+
return "human";
|
|
27
|
+
}
|
|
28
|
+
concat(chunk) {
|
|
29
|
+
return new HumanMessageChunk({
|
|
30
|
+
content: (0, base_js_1.mergeContent)(this.content, chunk.content),
|
|
31
|
+
additional_kwargs: (0, base_js_1._mergeDicts)(this.additional_kwargs, chunk.additional_kwargs),
|
|
32
|
+
response_metadata: (0, base_js_1._mergeDicts)(this.response_metadata, chunk.response_metadata),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.HumanMessageChunk = HumanMessageChunk;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageChunk, type MessageType } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a human message in a conversation.
|
|
4
|
+
*/
|
|
5
|
+
export declare class HumanMessage extends BaseMessage {
|
|
6
|
+
static lc_name(): string;
|
|
7
|
+
_getType(): MessageType;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a chunk of a human message, which can be concatenated with
|
|
11
|
+
* other human message chunks.
|
|
12
|
+
*/
|
|
13
|
+
export declare class HumanMessageChunk extends BaseMessageChunk {
|
|
14
|
+
static lc_name(): string;
|
|
15
|
+
_getType(): MessageType;
|
|
16
|
+
concat(chunk: HumanMessageChunk): HumanMessageChunk;
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseMessage, BaseMessageChunk, mergeContent, _mergeDicts, } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a human message in a conversation.
|
|
4
|
+
*/
|
|
5
|
+
export class HumanMessage extends BaseMessage {
|
|
6
|
+
static lc_name() {
|
|
7
|
+
return "HumanMessage";
|
|
8
|
+
}
|
|
9
|
+
_getType() {
|
|
10
|
+
return "human";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents a chunk of a human message, which can be concatenated with
|
|
15
|
+
* other human message chunks.
|
|
16
|
+
*/
|
|
17
|
+
export class HumanMessageChunk extends BaseMessageChunk {
|
|
18
|
+
static lc_name() {
|
|
19
|
+
return "HumanMessageChunk";
|
|
20
|
+
}
|
|
21
|
+
_getType() {
|
|
22
|
+
return "human";
|
|
23
|
+
}
|
|
24
|
+
concat(chunk) {
|
|
25
|
+
return new HumanMessageChunk({
|
|
26
|
+
content: mergeContent(this.content, chunk.content),
|
|
27
|
+
additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),
|
|
28
|
+
response_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|