@eggjs/langchain-decorator 0.0.0 → 4.0.2-beta.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/LICENSE +21 -0
- package/dist/builder/BoundModelMetaBuilder.d.ts +12 -0
- package/dist/builder/BoundModelMetaBuilder.js +20 -0
- package/dist/builder/GraphEdgeMetaBuilder.d.ts +12 -0
- package/dist/builder/GraphEdgeMetaBuilder.js +20 -0
- package/dist/builder/GraphMetaBuilder.d.ts +12 -0
- package/dist/builder/GraphMetaBuilder.js +20 -0
- package/dist/builder/GraphNodeMetaBuilder.d.ts +12 -0
- package/dist/builder/GraphNodeMetaBuilder.js +20 -0
- package/dist/builder/GraphToolMetaBuilder.d.ts +12 -0
- package/dist/builder/GraphToolMetaBuilder.js +20 -0
- package/dist/decorator/BoundModel.d.ts +10 -0
- package/dist/decorator/BoundModel.js +20 -0
- package/dist/decorator/Graph.d.ts +16 -0
- package/dist/decorator/Graph.js +24 -0
- package/dist/decorator/GraphEdge.d.ts +26 -0
- package/dist/decorator/GraphEdge.js +31 -0
- package/dist/decorator/GraphNode.d.ts +22 -0
- package/dist/decorator/GraphNode.js +29 -0
- package/dist/decorator/GraphTool.d.ts +12 -0
- package/dist/decorator/GraphTool.js +20 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +25 -0
- package/dist/model/BoundModelMetadata.d.ts +16 -0
- package/dist/model/BoundModelMetadata.js +14 -0
- package/dist/model/GraphEdgeMetadata.d.ts +14 -0
- package/dist/model/GraphEdgeMetadata.js +12 -0
- package/dist/model/GraphMetadata.d.ts +17 -0
- package/dist/model/GraphMetadata.js +16 -0
- package/dist/model/GraphNodeMetadata.d.ts +16 -0
- package/dist/model/GraphNodeMetadata.js +14 -0
- package/dist/model/GraphToolMetadata.d.ts +14 -0
- package/dist/model/GraphToolMetadata.js +11 -0
- package/dist/qualifier/ChatCheckpointSaverQualifier.d.ts +6 -0
- package/dist/qualifier/ChatCheckpointSaverQualifier.js +13 -0
- package/dist/qualifier/ChatModelQualifier.d.ts +6 -0
- package/dist/qualifier/ChatModelQualifier.js +13 -0
- package/dist/type/metadataKey.d.ts +9 -0
- package/dist/type/metadataKey.js +10 -0
- package/dist/util/BoundModelInfoUtil.d.ts +10 -0
- package/dist/util/BoundModelInfoUtil.js +15 -0
- package/dist/util/GraphEdgeInfoUtil.d.ts +10 -0
- package/dist/util/GraphEdgeInfoUtil.js +15 -0
- package/dist/util/GraphInfoUtil.d.ts +12 -0
- package/dist/util/GraphInfoUtil.js +20 -0
- package/dist/util/GraphNodeInfoUtil.d.ts +10 -0
- package/dist/util/GraphNodeInfoUtil.js +15 -0
- package/dist/util/GraphToolInfoUtil.d.ts +12 -0
- package/dist/util/GraphToolInfoUtil.js +20 -0
- package/dist/util/index.d.ts +6 -0
- package/dist/util/index.js +7 -0
- package/package.json +60 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present Alibaba Group Holding Limited and other contributors.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BoundModelMetadata } from "../model/BoundModelMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/BoundModelMetaBuilder.d.ts
|
|
5
|
+
declare class BoundModelMetaBuilder {
|
|
6
|
+
private readonly clazz;
|
|
7
|
+
constructor(clazz: EggProtoImplClass);
|
|
8
|
+
build(): BoundModelMetadata | undefined;
|
|
9
|
+
static create(clazz: EggProtoImplClass): BoundModelMetaBuilder;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BoundModelMetaBuilder };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BoundModelMetadata } from "../model/BoundModelMetadata.js";
|
|
2
|
+
import { BoundModelInfoUtil } from "../util/BoundModelInfoUtil.js";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/BoundModelMetaBuilder.ts
|
|
5
|
+
var BoundModelMetaBuilder = class BoundModelMetaBuilder {
|
|
6
|
+
clazz;
|
|
7
|
+
constructor(clazz) {
|
|
8
|
+
this.clazz = clazz;
|
|
9
|
+
}
|
|
10
|
+
build() {
|
|
11
|
+
const metadata = BoundModelInfoUtil.getBoundModelMetadata(this.clazz);
|
|
12
|
+
if (metadata) return new BoundModelMetadata(metadata);
|
|
13
|
+
}
|
|
14
|
+
static create(clazz) {
|
|
15
|
+
return new BoundModelMetaBuilder(clazz);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { BoundModelMetaBuilder };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GraphEdgeMetadata } from "../model/GraphEdgeMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphEdgeMetaBuilder.d.ts
|
|
5
|
+
declare class GraphEdgeMetaBuilder {
|
|
6
|
+
private readonly clazz;
|
|
7
|
+
constructor(clazz: EggProtoImplClass);
|
|
8
|
+
build(): GraphEdgeMetadata | undefined;
|
|
9
|
+
static create(clazz: EggProtoImplClass): GraphEdgeMetaBuilder;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphEdgeMetaBuilder };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphEdgeMetadata } from "../model/GraphEdgeMetadata.js";
|
|
2
|
+
import { GraphEdgeInfoUtil } from "../util/GraphEdgeInfoUtil.js";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphEdgeMetaBuilder.ts
|
|
5
|
+
var GraphEdgeMetaBuilder = class GraphEdgeMetaBuilder {
|
|
6
|
+
clazz;
|
|
7
|
+
constructor(clazz) {
|
|
8
|
+
this.clazz = clazz;
|
|
9
|
+
}
|
|
10
|
+
build() {
|
|
11
|
+
const metadata = GraphEdgeInfoUtil.getGraphEdgeMetadata(this.clazz);
|
|
12
|
+
if (metadata) return new GraphEdgeMetadata(metadata);
|
|
13
|
+
}
|
|
14
|
+
static create(clazz) {
|
|
15
|
+
return new GraphEdgeMetaBuilder(clazz);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphEdgeMetaBuilder };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GraphMetadata } from "../model/GraphMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphMetaBuilder.d.ts
|
|
5
|
+
declare class GraphMetaBuilder {
|
|
6
|
+
private readonly clazz;
|
|
7
|
+
constructor(clazz: EggProtoImplClass);
|
|
8
|
+
build(): GraphMetadata | undefined;
|
|
9
|
+
static create(clazz: EggProtoImplClass): GraphMetaBuilder;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphMetaBuilder };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphMetadata } from "../model/GraphMetadata.js";
|
|
2
|
+
import { GraphInfoUtil } from "../util/GraphInfoUtil.js";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphMetaBuilder.ts
|
|
5
|
+
var GraphMetaBuilder = class GraphMetaBuilder {
|
|
6
|
+
clazz;
|
|
7
|
+
constructor(clazz) {
|
|
8
|
+
this.clazz = clazz;
|
|
9
|
+
}
|
|
10
|
+
build() {
|
|
11
|
+
const metadata = GraphInfoUtil.getGraphMetadata(this.clazz);
|
|
12
|
+
if (metadata) return new GraphMetadata(metadata);
|
|
13
|
+
}
|
|
14
|
+
static create(clazz) {
|
|
15
|
+
return new GraphMetaBuilder(clazz);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphMetaBuilder };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GraphNodeMetadata } from "../model/GraphNodeMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphNodeMetaBuilder.d.ts
|
|
5
|
+
declare class GraphNodeMetaBuilder {
|
|
6
|
+
private readonly clazz;
|
|
7
|
+
constructor(clazz: EggProtoImplClass);
|
|
8
|
+
build(): GraphNodeMetadata | undefined;
|
|
9
|
+
static create(clazz: EggProtoImplClass): GraphNodeMetaBuilder;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphNodeMetaBuilder };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphNodeMetadata } from "../model/GraphNodeMetadata.js";
|
|
2
|
+
import { GraphNodeInfoUtil } from "../util/GraphNodeInfoUtil.js";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphNodeMetaBuilder.ts
|
|
5
|
+
var GraphNodeMetaBuilder = class GraphNodeMetaBuilder {
|
|
6
|
+
clazz;
|
|
7
|
+
constructor(clazz) {
|
|
8
|
+
this.clazz = clazz;
|
|
9
|
+
}
|
|
10
|
+
build() {
|
|
11
|
+
const metadata = GraphNodeInfoUtil.getGraphNodeMetadata(this.clazz);
|
|
12
|
+
if (metadata) return new GraphNodeMetadata(metadata);
|
|
13
|
+
}
|
|
14
|
+
static create(clazz) {
|
|
15
|
+
return new GraphNodeMetaBuilder(clazz);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphNodeMetaBuilder };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GraphToolMetadata } from "../model/GraphToolMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphToolMetaBuilder.d.ts
|
|
5
|
+
declare class GraphToolMetaBuilder {
|
|
6
|
+
private readonly clazz;
|
|
7
|
+
constructor(clazz: EggProtoImplClass);
|
|
8
|
+
build(): GraphToolMetadata | undefined;
|
|
9
|
+
static create(clazz: EggProtoImplClass): GraphToolMetaBuilder;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphToolMetaBuilder };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphToolMetadata } from "../model/GraphToolMetadata.js";
|
|
2
|
+
import { GraphToolInfoUtil } from "../util/GraphToolInfoUtil.js";
|
|
3
|
+
|
|
4
|
+
//#region src/builder/GraphToolMetaBuilder.ts
|
|
5
|
+
var GraphToolMetaBuilder = class GraphToolMetaBuilder {
|
|
6
|
+
clazz;
|
|
7
|
+
constructor(clazz) {
|
|
8
|
+
this.clazz = clazz;
|
|
9
|
+
}
|
|
10
|
+
build() {
|
|
11
|
+
const metadata = GraphToolInfoUtil.getGraphToolMetadata(this.clazz);
|
|
12
|
+
if (metadata) return new GraphToolMetadata(metadata);
|
|
13
|
+
}
|
|
14
|
+
static create(clazz) {
|
|
15
|
+
return new GraphToolMetaBuilder(clazz);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphToolMetaBuilder };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IBoundModelMetadata } from "../model/BoundModelMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
import { BaseChatOpenAI, ChatOpenAICallOptions } from "@langchain/openai";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/BoundModel.d.ts
|
|
6
|
+
declare function BoundModel(params: IBoundModelMetadata): (constructor: EggProtoImplClass) => void;
|
|
7
|
+
type BaseChatModel<T extends ChatOpenAICallOptions = ChatOpenAICallOptions> = InstanceType<typeof BaseChatOpenAI<T>> extends infer C ? C : never;
|
|
8
|
+
type TeggBoundModel<S, CallOptions extends ChatOpenAICallOptions = ChatOpenAICallOptions> = S & ReturnType<NonNullable<BaseChatModel<CallOptions>["bindTools"]>>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { BoundModel, TeggBoundModel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BoundModelInfoUtil } from "../util/BoundModelInfoUtil.js";
|
|
2
|
+
import { PrototypeUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
3
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
4
|
+
import { AccessLevel } from "@eggjs/tegg-types";
|
|
5
|
+
import { BaseChatOpenAI } from "@langchain/openai";
|
|
6
|
+
|
|
7
|
+
//#region src/decorator/BoundModel.ts
|
|
8
|
+
function BoundModel(params) {
|
|
9
|
+
return (constructor) => {
|
|
10
|
+
SingletonProto({
|
|
11
|
+
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
|
|
12
|
+
name: params?.name
|
|
13
|
+
})(constructor);
|
|
14
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
15
|
+
BoundModelInfoUtil.setBoundModelMetadata(params, constructor);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { BoundModel };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IGraphMetadata } from "../model/GraphMetadata.js";
|
|
2
|
+
import { AnnotationRoot, CompiledStateGraph, StateDefinition, StateGraph, StateType, UpdateType } from "@langchain/langgraph";
|
|
3
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/Graph.d.ts
|
|
6
|
+
declare function Graph<N$1 extends string = "", S$1 extends StateDefinition = StateDefinition>(params: IGraphMetadata): (constructor: EggProtoImplClass<AbstractStateGraph<N$1, S$1>>) => void;
|
|
7
|
+
interface IGraph<N$1 extends string = "", S$1 extends StateDefinition = StateDefinition> extends StateGraph<S$1, AnnotationRoot<S$1>["State"], UpdateType<S$1>, N$1> {
|
|
8
|
+
build?(): Promise<CompiledStateGraph<StateType<StateDefinition>, UpdateType<StateDefinition>, string, StateDefinition, StateDefinition, StateDefinition> | undefined>;
|
|
9
|
+
}
|
|
10
|
+
declare abstract class AbstractStateGraph<N$1 extends string = "", S$1 extends StateDefinition = StateDefinition> extends StateGraph<S$1, AnnotationRoot<S$1>["State"], UpdateType<S$1>, N$1> implements IGraph<N$1, S$1> {
|
|
11
|
+
private _names;
|
|
12
|
+
private _state;
|
|
13
|
+
}
|
|
14
|
+
type TeggCompiledStateGraph<G> = G extends AbstractStateGraph<infer N extends string, infer S extends StateDefinition> ? CompiledStateGraph<StateType<S>, UpdateType<S>, N, S, S> : never;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { AbstractStateGraph, Graph, IGraph, TeggCompiledStateGraph };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GraphInfoUtil } from "../util/GraphInfoUtil.js";
|
|
2
|
+
import { PrototypeUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
3
|
+
import { StateGraph } from "@langchain/langgraph";
|
|
4
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
5
|
+
import { AccessLevel } from "@eggjs/tegg-types";
|
|
6
|
+
|
|
7
|
+
//#region src/decorator/Graph.ts
|
|
8
|
+
function Graph(params) {
|
|
9
|
+
return (constructor) => {
|
|
10
|
+
SingletonProto({
|
|
11
|
+
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
|
|
12
|
+
name: params?.name
|
|
13
|
+
})(constructor);
|
|
14
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
15
|
+
GraphInfoUtil.setGraphMetadata(params, constructor);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var AbstractStateGraph = class extends StateGraph {
|
|
19
|
+
_names;
|
|
20
|
+
_state;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { AbstractStateGraph, Graph };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IGraphEdgeMetadata } from "../model/GraphEdgeMetadata.js";
|
|
2
|
+
import { AnnotationRoot, StateDefinition, UpdateType } from "@langchain/langgraph";
|
|
3
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/GraphEdge.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @description GraphEdge decorator
|
|
9
|
+
* @param {IGraphEdgeMetadata} params
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* @GraphEdge({
|
|
13
|
+
* fromNodeName: 'start', // 标记启动点,如果只有 fromNodeName 和 toNodeNames,那么就是单向边
|
|
14
|
+
* toNodeNames: ['end'], // 标记结束点,可以是多个,多个的时候就必须要实现 execute
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
* @return {Function}
|
|
18
|
+
*/
|
|
19
|
+
declare function GraphEdge<S extends StateDefinition = StateDefinition, N extends string = "__start__" | "__end__">(params: IGraphEdgeMetadata): (constructor: EggProtoImplClass<IGraphEdge<S, N>>) => void;
|
|
20
|
+
type GraphStateType<A extends StateDefinition = StateDefinition> = AnnotationRoot<A>["State"];
|
|
21
|
+
type GraphUpdateType<A extends StateDefinition = StateDefinition> = UpdateType<A>;
|
|
22
|
+
interface IGraphEdge<S extends StateDefinition = StateDefinition, N extends string = "__start__" | "__end__"> {
|
|
23
|
+
execute?(state: AnnotationRoot<S>["State"]): Promise<N | N[]>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { GraphEdge, GraphStateType, GraphUpdateType, IGraphEdge };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GraphEdgeInfoUtil } from "../util/GraphEdgeInfoUtil.js";
|
|
2
|
+
import { PrototypeUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
3
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
4
|
+
import { AccessLevel } from "@eggjs/tegg-types";
|
|
5
|
+
|
|
6
|
+
//#region src/decorator/GraphEdge.ts
|
|
7
|
+
/**
|
|
8
|
+
* @description GraphEdge decorator
|
|
9
|
+
* @param {IGraphEdgeMetadata} params
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* @GraphEdge({
|
|
13
|
+
* fromNodeName: 'start', // 标记启动点,如果只有 fromNodeName 和 toNodeNames,那么就是单向边
|
|
14
|
+
* toNodeNames: ['end'], // 标记结束点,可以是多个,多个的时候就必须要实现 execute
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
* @return {Function}
|
|
18
|
+
*/
|
|
19
|
+
function GraphEdge(params) {
|
|
20
|
+
return (constructor) => {
|
|
21
|
+
SingletonProto({
|
|
22
|
+
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
|
|
23
|
+
name: params?.name
|
|
24
|
+
})(constructor);
|
|
25
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
26
|
+
GraphEdgeInfoUtil.setGraphEdgeMetadata(params, constructor);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { GraphEdge };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IGraphNodeMetadata } from "../model/GraphNodeMetadata.js";
|
|
2
|
+
import { AnnotationRoot, Runtime, StateDefinition, StateGraph, UpdateType } from "@langchain/langgraph";
|
|
3
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
4
|
+
import { BaseChatOpenAI } from "@langchain/openai";
|
|
5
|
+
import { ToolNode } from "@langchain/langgraph/prebuilt";
|
|
6
|
+
import { ConfigurableModel } from "langchain/chat_models/universal";
|
|
7
|
+
|
|
8
|
+
//#region src/decorator/GraphNode.d.ts
|
|
9
|
+
declare function GraphNode<S extends StateDefinition = StateDefinition>(params: IGraphNodeMetadata): (constructor: EggProtoImplClass<IGraphNode<S> | TeggToolNode>) => void;
|
|
10
|
+
type StateGraphAddNodeOptions = Parameters<(typeof StateGraph)["prototype"]["addNode"]>[2];
|
|
11
|
+
type GraphRuntime<ContextType = Record<string, unknown>, InterruptType = any, WriterType = any> = Runtime<ContextType, InterruptType, WriterType>;
|
|
12
|
+
interface IGraphNode<S extends StateDefinition = StateDefinition, T = any> {
|
|
13
|
+
options?: StateGraphAddNodeOptions;
|
|
14
|
+
execute(state: AnnotationRoot<S>["State"], options?: GraphRuntime): Promise<UpdateType<S> & Record<string, any>> | Promise<ToolNode<T>>;
|
|
15
|
+
build?: (tools: Parameters<ConfigurableModel["bindTools"]>["0"]) => Promise<ReturnType<ConfigurableModel["bindTools"]> | ReturnType<BaseChatOpenAI<any>["bindTools"]>>;
|
|
16
|
+
}
|
|
17
|
+
declare class TeggToolNode implements IGraphNode {
|
|
18
|
+
toolNode: ToolNode;
|
|
19
|
+
execute(): Promise<ToolNode>;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { GraphNode, GraphRuntime, IGraphNode, StateGraphAddNodeOptions, TeggToolNode };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GraphNodeInfoUtil } from "../util/GraphNodeInfoUtil.js";
|
|
2
|
+
import { PrototypeUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
3
|
+
import { StateGraph } from "@langchain/langgraph";
|
|
4
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
5
|
+
import { AccessLevel } from "@eggjs/tegg-types";
|
|
6
|
+
import { BaseChatOpenAI } from "@langchain/openai";
|
|
7
|
+
import { ToolNode } from "@langchain/langgraph/prebuilt";
|
|
8
|
+
import { ConfigurableModel } from "langchain/chat_models/universal";
|
|
9
|
+
|
|
10
|
+
//#region src/decorator/GraphNode.ts
|
|
11
|
+
function GraphNode(params) {
|
|
12
|
+
return (constructor) => {
|
|
13
|
+
SingletonProto({
|
|
14
|
+
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
|
|
15
|
+
name: params?.name
|
|
16
|
+
})(constructor);
|
|
17
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
18
|
+
GraphNodeInfoUtil.setGraphNodeMetadata(params, constructor);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var TeggToolNode = class {
|
|
22
|
+
toolNode;
|
|
23
|
+
async execute() {
|
|
24
|
+
return this.toolNode;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { GraphNode, TeggToolNode };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IGraphToolMetadata } from "../model/GraphToolMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
import { DynamicStructuredTool, ToolSchemaBase } from "@langchain/core/tools";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/GraphTool.d.ts
|
|
6
|
+
declare function GraphTool<ToolSchema = ToolSchemaBase>(params: IGraphToolMetadata): (constructor: EggProtoImplClass<IGraphTool<ToolSchema>>) => void;
|
|
7
|
+
interface IGraphTool<ToolSchema = ToolSchemaBase> {
|
|
8
|
+
execute: DynamicStructuredTool<ToolSchema>["func"];
|
|
9
|
+
}
|
|
10
|
+
type IGraphStructuredTool<T extends IGraphTool> = DynamicStructuredTool<Parameters<T["execute"]>[0]>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphTool, IGraphStructuredTool, IGraphTool };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphToolInfoUtil } from "../util/GraphToolInfoUtil.js";
|
|
2
|
+
import { PrototypeUtil, SingletonProto } from "@eggjs/core-decorator";
|
|
3
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
4
|
+
import { AccessLevel } from "@eggjs/tegg-types";
|
|
5
|
+
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
6
|
+
|
|
7
|
+
//#region src/decorator/GraphTool.ts
|
|
8
|
+
function GraphTool(params) {
|
|
9
|
+
return (constructor) => {
|
|
10
|
+
SingletonProto({
|
|
11
|
+
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
|
|
12
|
+
name: params?.name
|
|
13
|
+
})(constructor);
|
|
14
|
+
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
|
|
15
|
+
GraphToolInfoUtil.setGraphToolMetadata(params, constructor);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphTool };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BoundModelMetadata, IBoundModelMetadata } from "./model/BoundModelMetadata.js";
|
|
2
|
+
import { BoundModelMetaBuilder } from "./builder/BoundModelMetaBuilder.js";
|
|
3
|
+
import { GraphEdgeMetadata, IGraphEdgeMetadata } from "./model/GraphEdgeMetadata.js";
|
|
4
|
+
import { GraphEdgeMetaBuilder } from "./builder/GraphEdgeMetaBuilder.js";
|
|
5
|
+
import { GraphMetadata, IGraphMetadata } from "./model/GraphMetadata.js";
|
|
6
|
+
import { GraphMetaBuilder } from "./builder/GraphMetaBuilder.js";
|
|
7
|
+
import { GraphNodeMetadata, IGraphNodeMetadata } from "./model/GraphNodeMetadata.js";
|
|
8
|
+
import { GraphNodeMetaBuilder } from "./builder/GraphNodeMetaBuilder.js";
|
|
9
|
+
import { GraphToolMetadata, IGraphToolMetadata } from "./model/GraphToolMetadata.js";
|
|
10
|
+
import { GraphToolMetaBuilder } from "./builder/GraphToolMetaBuilder.js";
|
|
11
|
+
import { BoundModel, TeggBoundModel } from "./decorator/BoundModel.js";
|
|
12
|
+
import { AbstractStateGraph, Graph, IGraph, TeggCompiledStateGraph } from "./decorator/Graph.js";
|
|
13
|
+
import { GraphEdge, GraphStateType, GraphUpdateType, IGraphEdge } from "./decorator/GraphEdge.js";
|
|
14
|
+
import { GraphNode, GraphRuntime, IGraphNode, StateGraphAddNodeOptions, TeggToolNode } from "./decorator/GraphNode.js";
|
|
15
|
+
import { GraphTool, IGraphStructuredTool, IGraphTool } from "./decorator/GraphTool.js";
|
|
16
|
+
import { BoundModelInfoUtil } from "./util/BoundModelInfoUtil.js";
|
|
17
|
+
import { GraphEdgeInfoUtil } from "./util/GraphEdgeInfoUtil.js";
|
|
18
|
+
import { GraphInfoUtil } from "./util/GraphInfoUtil.js";
|
|
19
|
+
import { GraphNodeInfoUtil } from "./util/GraphNodeInfoUtil.js";
|
|
20
|
+
import { GraphToolInfoUtil } from "./util/GraphToolInfoUtil.js";
|
|
21
|
+
import { ChatModelInjectName, ChatModelQualifier, ChatModelQualifierAttribute } from "./qualifier/ChatModelQualifier.js";
|
|
22
|
+
import { ChatCheckpointSaverInjectName, ChatCheckpointSaverQualifier, ChatCheckpointSaverQualifierAttribute } from "./qualifier/ChatCheckpointSaverQualifier.js";
|
|
23
|
+
import { BOUND_MODEL_METADATA, GRAPH_EDGE_METADATA, GRAPH_GRAPH_METADATA, GRAPH_NODE_METADATA, GRAPH_TOOL_METADATA, PROMPT_KEY_METADATA } from "./type/metadataKey.js";
|
|
24
|
+
export { AbstractStateGraph, BOUND_MODEL_METADATA, BoundModel, BoundModelInfoUtil, BoundModelMetaBuilder, BoundModelMetadata, ChatCheckpointSaverInjectName, ChatCheckpointSaverQualifier, ChatCheckpointSaverQualifierAttribute, ChatModelInjectName, ChatModelQualifier, ChatModelQualifierAttribute, GRAPH_EDGE_METADATA, GRAPH_GRAPH_METADATA, GRAPH_NODE_METADATA, GRAPH_TOOL_METADATA, Graph, GraphEdge, GraphEdgeInfoUtil, GraphEdgeMetaBuilder, GraphEdgeMetadata, GraphInfoUtil, GraphMetaBuilder, GraphMetadata, GraphNode, GraphNodeInfoUtil, GraphNodeMetaBuilder, GraphNodeMetadata, GraphRuntime, GraphStateType, GraphTool, GraphToolInfoUtil, GraphToolMetaBuilder, GraphToolMetadata, GraphUpdateType, IBoundModelMetadata, IGraph, IGraphEdge, IGraphEdgeMetadata, IGraphMetadata, IGraphNode, IGraphNodeMetadata, IGraphStructuredTool, IGraphTool, IGraphToolMetadata, PROMPT_KEY_METADATA, StateGraphAddNodeOptions, TeggBoundModel, TeggCompiledStateGraph, TeggToolNode };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BoundModelMetadata } from "./model/BoundModelMetadata.js";
|
|
2
|
+
import { BOUND_MODEL_METADATA, GRAPH_EDGE_METADATA, GRAPH_GRAPH_METADATA, GRAPH_NODE_METADATA, GRAPH_TOOL_METADATA, PROMPT_KEY_METADATA } from "./type/metadataKey.js";
|
|
3
|
+
import { BoundModelInfoUtil } from "./util/BoundModelInfoUtil.js";
|
|
4
|
+
import { BoundModelMetaBuilder } from "./builder/BoundModelMetaBuilder.js";
|
|
5
|
+
import { GraphEdgeMetadata } from "./model/GraphEdgeMetadata.js";
|
|
6
|
+
import { GraphEdgeInfoUtil } from "./util/GraphEdgeInfoUtil.js";
|
|
7
|
+
import { GraphEdgeMetaBuilder } from "./builder/GraphEdgeMetaBuilder.js";
|
|
8
|
+
import { GraphMetadata } from "./model/GraphMetadata.js";
|
|
9
|
+
import { GraphInfoUtil } from "./util/GraphInfoUtil.js";
|
|
10
|
+
import { GraphMetaBuilder } from "./builder/GraphMetaBuilder.js";
|
|
11
|
+
import { GraphNodeMetadata } from "./model/GraphNodeMetadata.js";
|
|
12
|
+
import { GraphNodeInfoUtil } from "./util/GraphNodeInfoUtil.js";
|
|
13
|
+
import { GraphNodeMetaBuilder } from "./builder/GraphNodeMetaBuilder.js";
|
|
14
|
+
import { GraphToolMetadata } from "./model/GraphToolMetadata.js";
|
|
15
|
+
import { GraphToolInfoUtil } from "./util/GraphToolInfoUtil.js";
|
|
16
|
+
import { GraphToolMetaBuilder } from "./builder/GraphToolMetaBuilder.js";
|
|
17
|
+
import { BoundModel } from "./decorator/BoundModel.js";
|
|
18
|
+
import { AbstractStateGraph, Graph } from "./decorator/Graph.js";
|
|
19
|
+
import { GraphEdge } from "./decorator/GraphEdge.js";
|
|
20
|
+
import { GraphNode, TeggToolNode } from "./decorator/GraphNode.js";
|
|
21
|
+
import { GraphTool } from "./decorator/GraphTool.js";
|
|
22
|
+
import { ChatModelInjectName, ChatModelQualifier, ChatModelQualifierAttribute } from "./qualifier/ChatModelQualifier.js";
|
|
23
|
+
import { ChatCheckpointSaverInjectName, ChatCheckpointSaverQualifier, ChatCheckpointSaverQualifierAttribute } from "./qualifier/ChatCheckpointSaverQualifier.js";
|
|
24
|
+
|
|
25
|
+
export { AbstractStateGraph, BOUND_MODEL_METADATA, BoundModel, BoundModelInfoUtil, BoundModelMetaBuilder, BoundModelMetadata, ChatCheckpointSaverInjectName, ChatCheckpointSaverQualifier, ChatCheckpointSaverQualifierAttribute, ChatModelInjectName, ChatModelQualifier, ChatModelQualifierAttribute, GRAPH_EDGE_METADATA, GRAPH_GRAPH_METADATA, GRAPH_NODE_METADATA, GRAPH_TOOL_METADATA, Graph, GraphEdge, GraphEdgeInfoUtil, GraphEdgeMetaBuilder, GraphEdgeMetadata, GraphInfoUtil, GraphMetaBuilder, GraphMetadata, GraphNode, GraphNodeInfoUtil, GraphNodeMetaBuilder, GraphNodeMetadata, GraphTool, GraphToolInfoUtil, GraphToolMetaBuilder, GraphToolMetadata, PROMPT_KEY_METADATA, TeggToolNode };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EggProtoImplClass, SingletonProtoParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/model/BoundModelMetadata.d.ts
|
|
4
|
+
interface IBoundModelMetadata extends SingletonProtoParams {
|
|
5
|
+
modelName: string;
|
|
6
|
+
tools?: EggProtoImplClass[];
|
|
7
|
+
mcpServers?: string[];
|
|
8
|
+
}
|
|
9
|
+
declare class BoundModelMetadata {
|
|
10
|
+
modelName: string;
|
|
11
|
+
tools?: EggProtoImplClass[];
|
|
12
|
+
mcpServers?: string[];
|
|
13
|
+
constructor(params: IBoundModelMetadata);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { BoundModelMetadata, IBoundModelMetadata };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/model/BoundModelMetadata.ts
|
|
2
|
+
var BoundModelMetadata = class {
|
|
3
|
+
modelName;
|
|
4
|
+
tools;
|
|
5
|
+
mcpServers;
|
|
6
|
+
constructor(params) {
|
|
7
|
+
this.modelName = params.modelName;
|
|
8
|
+
this.tools = params.tools;
|
|
9
|
+
this.mcpServers = params.mcpServers;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { BoundModelMetadata };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SingletonProtoParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/model/GraphEdgeMetadata.d.ts
|
|
4
|
+
interface IGraphEdgeMetadata extends SingletonProtoParams {
|
|
5
|
+
fromNodeName: string;
|
|
6
|
+
toNodeNames: string[];
|
|
7
|
+
}
|
|
8
|
+
declare class GraphEdgeMetadata {
|
|
9
|
+
fromNodeName: string;
|
|
10
|
+
toNodeNames: string[];
|
|
11
|
+
constructor(params: IGraphEdgeMetadata);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GraphEdgeMetadata, IGraphEdgeMetadata };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/model/GraphEdgeMetadata.ts
|
|
2
|
+
var GraphEdgeMetadata = class {
|
|
3
|
+
fromNodeName;
|
|
4
|
+
toNodeNames;
|
|
5
|
+
constructor(params) {
|
|
6
|
+
this.fromNodeName = params.fromNodeName;
|
|
7
|
+
this.toNodeNames = params.toNodeNames;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphEdgeMetadata };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCheckpointSaver } from "@langchain/langgraph";
|
|
2
|
+
import { EggProtoImplClass, SingletonProtoParams } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/model/GraphMetadata.d.ts
|
|
5
|
+
interface IGraphMetadata extends SingletonProtoParams {
|
|
6
|
+
nodes?: EggProtoImplClass[];
|
|
7
|
+
edges?: EggProtoImplClass[];
|
|
8
|
+
checkpoint?: EggProtoImplClass<BaseCheckpointSaver> | string;
|
|
9
|
+
}
|
|
10
|
+
declare class GraphMetadata implements IGraphMetadata {
|
|
11
|
+
nodes?: EggProtoImplClass[];
|
|
12
|
+
edges?: EggProtoImplClass[];
|
|
13
|
+
checkpoint?: EggProtoImplClass<BaseCheckpointSaver> | string;
|
|
14
|
+
constructor(params: IGraphMetadata);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GraphMetadata, IGraphMetadata };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCheckpointSaver } from "@langchain/langgraph";
|
|
2
|
+
|
|
3
|
+
//#region src/model/GraphMetadata.ts
|
|
4
|
+
var GraphMetadata = class {
|
|
5
|
+
nodes;
|
|
6
|
+
edges;
|
|
7
|
+
checkpoint;
|
|
8
|
+
constructor(params) {
|
|
9
|
+
this.nodes = params.nodes;
|
|
10
|
+
this.edges = params.edges;
|
|
11
|
+
this.checkpoint = params.checkpoint;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { GraphMetadata };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EggProtoImplClass, SingletonProtoParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/model/GraphNodeMetadata.d.ts
|
|
4
|
+
interface IGraphNodeMetadata extends SingletonProtoParams {
|
|
5
|
+
nodeName: string;
|
|
6
|
+
tools?: EggProtoImplClass[];
|
|
7
|
+
mcpServers?: string[];
|
|
8
|
+
}
|
|
9
|
+
declare class GraphNodeMetadata {
|
|
10
|
+
nodeName: string;
|
|
11
|
+
tools?: EggProtoImplClass[];
|
|
12
|
+
mcpServers?: string[];
|
|
13
|
+
constructor(params: IGraphNodeMetadata);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { GraphNodeMetadata, IGraphNodeMetadata };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/model/GraphNodeMetadata.ts
|
|
2
|
+
var GraphNodeMetadata = class {
|
|
3
|
+
nodeName;
|
|
4
|
+
tools;
|
|
5
|
+
mcpServers;
|
|
6
|
+
constructor(params) {
|
|
7
|
+
this.nodeName = params.nodeName;
|
|
8
|
+
this.tools = params.tools;
|
|
9
|
+
this.mcpServers = params.mcpServers;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GraphNodeMetadata };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SingletonProtoParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/model/GraphToolMetadata.d.ts
|
|
4
|
+
interface IGraphToolMetadata extends SingletonProtoParams {
|
|
5
|
+
toolName: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
declare class GraphToolMetadata implements IGraphToolMetadata {
|
|
9
|
+
toolName: string;
|
|
10
|
+
description: string;
|
|
11
|
+
constructor(params: IGraphToolMetadata);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GraphToolMetadata, IGraphToolMetadata };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/qualifier/ChatCheckpointSaverQualifier.d.ts
|
|
2
|
+
declare const ChatCheckpointSaverQualifierAttribute: symbol;
|
|
3
|
+
declare const ChatCheckpointSaverInjectName = "chatCheckpointSaver";
|
|
4
|
+
declare function ChatCheckpointSaverQualifier(chatCheckpointSaverName: string): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ChatCheckpointSaverInjectName, ChatCheckpointSaverQualifier, ChatCheckpointSaverQualifierAttribute };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QualifierUtil } from "@eggjs/core-decorator";
|
|
2
|
+
|
|
3
|
+
//#region src/qualifier/ChatCheckpointSaverQualifier.ts
|
|
4
|
+
const ChatCheckpointSaverQualifierAttribute = Symbol.for("Qualifier.ChatCheckpointSaver");
|
|
5
|
+
const ChatCheckpointSaverInjectName = "chatCheckpointSaver";
|
|
6
|
+
function ChatCheckpointSaverQualifier(chatCheckpointSaverName) {
|
|
7
|
+
return function(target, propertyKey, parameterIndex) {
|
|
8
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, ChatCheckpointSaverQualifierAttribute, chatCheckpointSaverName);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ChatCheckpointSaverInjectName, ChatCheckpointSaverQualifier, ChatCheckpointSaverQualifierAttribute };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/qualifier/ChatModelQualifier.d.ts
|
|
2
|
+
declare const ChatModelQualifierAttribute: symbol;
|
|
3
|
+
declare const ChatModelInjectName = "chatModel";
|
|
4
|
+
declare function ChatModelQualifier(chatModelName: string): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ChatModelInjectName, ChatModelQualifier, ChatModelQualifierAttribute };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QualifierUtil } from "@eggjs/core-decorator";
|
|
2
|
+
|
|
3
|
+
//#region src/qualifier/ChatModelQualifier.ts
|
|
4
|
+
const ChatModelQualifierAttribute = Symbol.for("Qualifier.ChatModel");
|
|
5
|
+
const ChatModelInjectName = "chatModel";
|
|
6
|
+
function ChatModelQualifier(chatModelName) {
|
|
7
|
+
return function(target, propertyKey, parameterIndex) {
|
|
8
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, ChatModelQualifierAttribute, chatModelName);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ChatModelInjectName, ChatModelQualifier, ChatModelQualifierAttribute };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/type/metadataKey.d.ts
|
|
2
|
+
declare const GRAPH_TOOL_METADATA: symbol;
|
|
3
|
+
declare const GRAPH_EDGE_METADATA: symbol;
|
|
4
|
+
declare const GRAPH_NODE_METADATA: symbol;
|
|
5
|
+
declare const GRAPH_GRAPH_METADATA: symbol;
|
|
6
|
+
declare const PROMPT_KEY_METADATA: symbol;
|
|
7
|
+
declare const BOUND_MODEL_METADATA: symbol;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { BOUND_MODEL_METADATA, GRAPH_EDGE_METADATA, GRAPH_GRAPH_METADATA, GRAPH_NODE_METADATA, GRAPH_TOOL_METADATA, PROMPT_KEY_METADATA };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/type/metadataKey.ts
|
|
2
|
+
const GRAPH_TOOL_METADATA = Symbol.for("EggPrototype#graph#tool#metadata");
|
|
3
|
+
const GRAPH_EDGE_METADATA = Symbol.for("EggPrototype#graph#edge#metadata");
|
|
4
|
+
const GRAPH_NODE_METADATA = Symbol.for("EggPrototype#graph#node#metadata");
|
|
5
|
+
const GRAPH_GRAPH_METADATA = Symbol.for("EggPrototype#graph#graph#metadata");
|
|
6
|
+
const PROMPT_KEY_METADATA = Symbol.for("EggPrototype#prompt#key#metadata");
|
|
7
|
+
const BOUND_MODEL_METADATA = Symbol.for("EggPrototype#bound#model#metadata");
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { BOUND_MODEL_METADATA, GRAPH_EDGE_METADATA, GRAPH_GRAPH_METADATA, GRAPH_NODE_METADATA, GRAPH_TOOL_METADATA, PROMPT_KEY_METADATA };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IBoundModelMetadata } from "../model/BoundModelMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/util/BoundModelInfoUtil.d.ts
|
|
5
|
+
declare class BoundModelInfoUtil {
|
|
6
|
+
static setBoundModelMetadata(metadata: IBoundModelMetadata, clazz: EggProtoImplClass): void;
|
|
7
|
+
static getBoundModelMetadata(clazz: EggProtoImplClass): IBoundModelMetadata | undefined;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { BoundModelInfoUtil };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BOUND_MODEL_METADATA } from "../type/metadataKey.js";
|
|
2
|
+
import { MetadataUtil } from "@eggjs/core-decorator";
|
|
3
|
+
|
|
4
|
+
//#region src/util/BoundModelInfoUtil.ts
|
|
5
|
+
var BoundModelInfoUtil = class {
|
|
6
|
+
static setBoundModelMetadata(metadata, clazz) {
|
|
7
|
+
MetadataUtil.defineMetaData(BOUND_MODEL_METADATA, metadata, clazz);
|
|
8
|
+
}
|
|
9
|
+
static getBoundModelMetadata(clazz) {
|
|
10
|
+
return MetadataUtil.getMetaData(BOUND_MODEL_METADATA, clazz);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BoundModelInfoUtil };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IGraphEdgeMetadata } from "../model/GraphEdgeMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphEdgeInfoUtil.d.ts
|
|
5
|
+
declare class GraphEdgeInfoUtil {
|
|
6
|
+
static setGraphEdgeMetadata(metadata: IGraphEdgeMetadata, clazz: EggProtoImplClass): void;
|
|
7
|
+
static getGraphEdgeMetadata(clazz: EggProtoImplClass): IGraphEdgeMetadata | undefined;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GraphEdgeInfoUtil };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GRAPH_EDGE_METADATA } from "../type/metadataKey.js";
|
|
2
|
+
import { MetadataUtil } from "@eggjs/core-decorator";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphEdgeInfoUtil.ts
|
|
5
|
+
var GraphEdgeInfoUtil = class {
|
|
6
|
+
static setGraphEdgeMetadata(metadata, clazz) {
|
|
7
|
+
MetadataUtil.defineMetaData(GRAPH_EDGE_METADATA, metadata, clazz);
|
|
8
|
+
}
|
|
9
|
+
static getGraphEdgeMetadata(clazz) {
|
|
10
|
+
return MetadataUtil.getMetaData(GRAPH_EDGE_METADATA, clazz);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { GraphEdgeInfoUtil };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IGraphMetadata } from "../model/GraphMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphInfoUtil.d.ts
|
|
5
|
+
declare class GraphInfoUtil {
|
|
6
|
+
static graphMap: Map<EggProtoImplClass, IGraphMetadata>;
|
|
7
|
+
static setGraphMetadata(metadata: IGraphMetadata, clazz: EggProtoImplClass): void;
|
|
8
|
+
static getGraphMetadata(clazz: EggProtoImplClass): IGraphMetadata | undefined;
|
|
9
|
+
static getAllGraphMetadata(): Map<EggProtoImplClass, IGraphMetadata>;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphInfoUtil };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GRAPH_GRAPH_METADATA } from "../type/metadataKey.js";
|
|
2
|
+
import { MetadataUtil } from "@eggjs/core-decorator";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphInfoUtil.ts
|
|
5
|
+
var GraphInfoUtil = class GraphInfoUtil {
|
|
6
|
+
static graphMap = /* @__PURE__ */ new Map();
|
|
7
|
+
static setGraphMetadata(metadata, clazz) {
|
|
8
|
+
MetadataUtil.defineMetaData(GRAPH_GRAPH_METADATA, metadata, clazz);
|
|
9
|
+
GraphInfoUtil.graphMap.set(clazz, metadata);
|
|
10
|
+
}
|
|
11
|
+
static getGraphMetadata(clazz) {
|
|
12
|
+
return MetadataUtil.getMetaData(GRAPH_GRAPH_METADATA, clazz);
|
|
13
|
+
}
|
|
14
|
+
static getAllGraphMetadata() {
|
|
15
|
+
return GraphInfoUtil.graphMap;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphInfoUtil };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IGraphNodeMetadata } from "../model/GraphNodeMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphNodeInfoUtil.d.ts
|
|
5
|
+
declare class GraphNodeInfoUtil {
|
|
6
|
+
static setGraphNodeMetadata(metadata: IGraphNodeMetadata, clazz: EggProtoImplClass): void;
|
|
7
|
+
static getGraphNodeMetadata(clazz: EggProtoImplClass): IGraphNodeMetadata | undefined;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GraphNodeInfoUtil };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GRAPH_NODE_METADATA } from "../type/metadataKey.js";
|
|
2
|
+
import { MetadataUtil } from "@eggjs/core-decorator";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphNodeInfoUtil.ts
|
|
5
|
+
var GraphNodeInfoUtil = class {
|
|
6
|
+
static setGraphNodeMetadata(metadata, clazz) {
|
|
7
|
+
MetadataUtil.defineMetaData(GRAPH_NODE_METADATA, metadata, clazz);
|
|
8
|
+
}
|
|
9
|
+
static getGraphNodeMetadata(clazz) {
|
|
10
|
+
return MetadataUtil.getMetaData(GRAPH_NODE_METADATA, clazz);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { GraphNodeInfoUtil };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IGraphToolMetadata } from "../model/GraphToolMetadata.js";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphToolInfoUtil.d.ts
|
|
5
|
+
declare class GraphToolInfoUtil {
|
|
6
|
+
static graphToolMap: Map<EggProtoImplClass, IGraphToolMetadata>;
|
|
7
|
+
static setGraphToolMetadata(metadata: IGraphToolMetadata, clazz: EggProtoImplClass): void;
|
|
8
|
+
static getGraphToolMetadata(clazz: EggProtoImplClass): IGraphToolMetadata | undefined;
|
|
9
|
+
static getAllGraphToolMetadata(): Map<EggProtoImplClass, IGraphToolMetadata>;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GraphToolInfoUtil };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GRAPH_TOOL_METADATA } from "../type/metadataKey.js";
|
|
2
|
+
import { MetadataUtil } from "@eggjs/core-decorator";
|
|
3
|
+
|
|
4
|
+
//#region src/util/GraphToolInfoUtil.ts
|
|
5
|
+
var GraphToolInfoUtil = class GraphToolInfoUtil {
|
|
6
|
+
static graphToolMap = /* @__PURE__ */ new Map();
|
|
7
|
+
static setGraphToolMetadata(metadata, clazz) {
|
|
8
|
+
MetadataUtil.defineMetaData(GRAPH_TOOL_METADATA, metadata, clazz);
|
|
9
|
+
GraphToolInfoUtil.graphToolMap.set(clazz, metadata);
|
|
10
|
+
}
|
|
11
|
+
static getGraphToolMetadata(clazz) {
|
|
12
|
+
return MetadataUtil.getMetaData(GRAPH_TOOL_METADATA, clazz);
|
|
13
|
+
}
|
|
14
|
+
static getAllGraphToolMetadata() {
|
|
15
|
+
return GraphToolInfoUtil.graphToolMap;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GraphToolInfoUtil };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BoundModelInfoUtil } from "./BoundModelInfoUtil.js";
|
|
2
|
+
import { GraphEdgeInfoUtil } from "./GraphEdgeInfoUtil.js";
|
|
3
|
+
import { GraphInfoUtil } from "./GraphInfoUtil.js";
|
|
4
|
+
import { GraphNodeInfoUtil } from "./GraphNodeInfoUtil.js";
|
|
5
|
+
import { GraphToolInfoUtil } from "./GraphToolInfoUtil.js";
|
|
6
|
+
export { BoundModelInfoUtil, GraphEdgeInfoUtil, GraphInfoUtil, GraphNodeInfoUtil, GraphToolInfoUtil };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BoundModelInfoUtil } from "./BoundModelInfoUtil.js";
|
|
2
|
+
import { GraphEdgeInfoUtil } from "./GraphEdgeInfoUtil.js";
|
|
3
|
+
import { GraphInfoUtil } from "./GraphInfoUtil.js";
|
|
4
|
+
import { GraphNodeInfoUtil } from "./GraphNodeInfoUtil.js";
|
|
5
|
+
import { GraphToolInfoUtil } from "./GraphToolInfoUtil.js";
|
|
6
|
+
|
|
7
|
+
export { BoundModelInfoUtil, GraphEdgeInfoUtil, GraphInfoUtil, GraphNodeInfoUtil, GraphToolInfoUtil };
|
package/package.json
CHANGED
|
@@ -1,31 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/langchain-decorator",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.2-beta.0",
|
|
4
|
+
"description": "tegg langchain decorator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"egg",
|
|
7
|
-
"
|
|
7
|
+
"langchain",
|
|
8
|
+
"tegg",
|
|
9
|
+
"typescript"
|
|
8
10
|
],
|
|
9
|
-
"homepage": "https://github.com/eggjs/egg/tree/next/
|
|
11
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/tegg/core/langchain-decorator",
|
|
10
12
|
"bugs": {
|
|
11
13
|
"url": "https://github.com/eggjs/egg/issues"
|
|
12
14
|
},
|
|
13
15
|
"license": "MIT",
|
|
14
|
-
"author": "
|
|
16
|
+
"author": "akitaSummer <akitasummer@outlook.com>",
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
17
19
|
"url": "git+https://github.com/eggjs/egg.git",
|
|
18
|
-
"directory": "
|
|
20
|
+
"directory": "tegg/core/langchain-decorator"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./dist/index.js",
|
|
31
|
+
"./builder/BoundModelMetaBuilder": "./dist/builder/BoundModelMetaBuilder.js",
|
|
32
|
+
"./builder/GraphEdgeMetaBuilder": "./dist/builder/GraphEdgeMetaBuilder.js",
|
|
33
|
+
"./builder/GraphMetaBuilder": "./dist/builder/GraphMetaBuilder.js",
|
|
34
|
+
"./builder/GraphNodeMetaBuilder": "./dist/builder/GraphNodeMetaBuilder.js",
|
|
35
|
+
"./builder/GraphToolMetaBuilder": "./dist/builder/GraphToolMetaBuilder.js",
|
|
36
|
+
"./decorator/BoundModel": "./dist/decorator/BoundModel.js",
|
|
37
|
+
"./decorator/Graph": "./dist/decorator/Graph.js",
|
|
38
|
+
"./decorator/GraphEdge": "./dist/decorator/GraphEdge.js",
|
|
39
|
+
"./decorator/GraphNode": "./dist/decorator/GraphNode.js",
|
|
40
|
+
"./decorator/GraphTool": "./dist/decorator/GraphTool.js",
|
|
41
|
+
"./model/BoundModelMetadata": "./dist/model/BoundModelMetadata.js",
|
|
42
|
+
"./model/GraphEdgeMetadata": "./dist/model/GraphEdgeMetadata.js",
|
|
43
|
+
"./model/GraphMetadata": "./dist/model/GraphMetadata.js",
|
|
44
|
+
"./model/GraphNodeMetadata": "./dist/model/GraphNodeMetadata.js",
|
|
45
|
+
"./model/GraphToolMetadata": "./dist/model/GraphToolMetadata.js",
|
|
46
|
+
"./qualifier/ChatCheckpointSaverQualifier": "./dist/qualifier/ChatCheckpointSaverQualifier.js",
|
|
47
|
+
"./qualifier/ChatModelQualifier": "./dist/qualifier/ChatModelQualifier.js",
|
|
48
|
+
"./type/metadataKey": "./dist/type/metadataKey.js",
|
|
49
|
+
"./util": "./dist/util/index.js",
|
|
50
|
+
"./util/BoundModelInfoUtil": "./dist/util/BoundModelInfoUtil.js",
|
|
51
|
+
"./util/GraphEdgeInfoUtil": "./dist/util/GraphEdgeInfoUtil.js",
|
|
52
|
+
"./util/GraphInfoUtil": "./dist/util/GraphInfoUtil.js",
|
|
53
|
+
"./util/GraphNodeInfoUtil": "./dist/util/GraphNodeInfoUtil.js",
|
|
54
|
+
"./util/GraphToolInfoUtil": "./dist/util/GraphToolInfoUtil.js",
|
|
55
|
+
"./package.json": "./package.json"
|
|
19
56
|
},
|
|
20
57
|
"publishConfig": {
|
|
21
58
|
"access": "public"
|
|
22
59
|
},
|
|
23
60
|
"dependencies": {
|
|
61
|
+
"@langchain/core": "^1.1.1",
|
|
62
|
+
"@langchain/langgraph": "^1.0.2",
|
|
63
|
+
"@langchain/openai": "^1.1.0",
|
|
64
|
+
"langchain": "^1.1.2",
|
|
65
|
+
"@eggjs/core-decorator": "4.0.2-beta.0",
|
|
66
|
+
"@eggjs/tegg-types": "4.0.2-beta.0",
|
|
67
|
+
"@eggjs/tegg-common-util": "4.0.2-beta.0"
|
|
24
68
|
},
|
|
25
69
|
"devDependencies": {
|
|
70
|
+
"@types/node": "^24.10.2",
|
|
71
|
+
"typescript": "^5.9.3",
|
|
72
|
+
"vitest": "^4.0.15",
|
|
73
|
+
"zod": "^3.24.1",
|
|
74
|
+
"@eggjs/controller-decorator": "4.0.2-beta.0"
|
|
26
75
|
},
|
|
27
76
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
77
|
+
"node": ">=22.18.0"
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"typecheck": "tsgo --noEmit"
|
|
29
81
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
82
|
+
}
|