@eggjs/tegg-langchain 0.0.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/README.md +20 -0
- package/app.d.ts +8 -0
- package/app.js +55 -0
- package/index.d.ts +10 -0
- package/index.js +27 -0
- package/lib/ChatModelHelper.d.ts +8 -0
- package/lib/ChatModelHelper.js +16 -0
- package/lib/ChatOpenAI.d.ts +7 -0
- package/lib/ChatOpenAI.js +63 -0
- package/lib/boundModel/BoundModelObjectHook.d.ts +5 -0
- package/lib/boundModel/BoundModelObjectHook.js +112 -0
- package/lib/config/QualifierUtil.d.ts +8 -0
- package/lib/config/QualifierUtil.js +17 -0
- package/lib/graph/CompiledStateGraphObject.d.ts +25 -0
- package/lib/graph/CompiledStateGraphObject.js +113 -0
- package/lib/graph/CompiledStateGraphProto.d.ts +21 -0
- package/lib/graph/CompiledStateGraphProto.js +42 -0
- package/lib/graph/GraphBuildHook.d.ts +2 -0
- package/lib/graph/GraphBuildHook.js +24 -0
- package/lib/graph/GraphLoadUnitHook.d.ts +12 -0
- package/lib/graph/GraphLoadUnitHook.js +48 -0
- package/lib/graph/GraphObjectHook.d.ts +5 -0
- package/lib/graph/GraphObjectHook.js +142 -0
- package/lib/graph/GraphPrototypeHook.d.ts +20 -0
- package/lib/graph/GraphPrototypeHook.js +253 -0
- package/lib/tracing/LangGraphTracer.d.ts +8 -0
- package/lib/tracing/LangGraphTracer.js +40 -0
- package/lib/util.d.ts +4 -0
- package/lib/util.js +27 -0
- package/package.json +106 -0
- package/typings/index.d.ts +132 -0
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eggjs/tegg-langchain",
|
|
3
|
+
"eggPlugin": {
|
|
4
|
+
"name": "teggLangChain",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"tegg"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"eggModule": {
|
|
10
|
+
"name": "teggLangChain"
|
|
11
|
+
},
|
|
12
|
+
"main": "index.js",
|
|
13
|
+
"version": "0.0.0",
|
|
14
|
+
"description": "langchain for egg",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"egg",
|
|
17
|
+
"plugin",
|
|
18
|
+
"typescript",
|
|
19
|
+
"module",
|
|
20
|
+
"tegg",
|
|
21
|
+
"langchain"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
"app.js",
|
|
25
|
+
"app.d.ts",
|
|
26
|
+
"index.js",
|
|
27
|
+
"index.d.ts",
|
|
28
|
+
"lib/**/*.js",
|
|
29
|
+
"lib/**/*.d.ts",
|
|
30
|
+
"app/**/*.js",
|
|
31
|
+
"app/**/*.d.ts",
|
|
32
|
+
"typings/*.d.ts"
|
|
33
|
+
],
|
|
34
|
+
"types": "typings/index.d.ts",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "mocha",
|
|
37
|
+
"clean": "tsc -b --clean",
|
|
38
|
+
"tsc": "npm run clean && tsc -p ./tsconfig.json",
|
|
39
|
+
"tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json",
|
|
40
|
+
"prepublishOnly": "npm run tsc:pub"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/eggjs/tegg",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/eggjs/tegg/issues"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+ssh://git@github.com/eggjs/tegg.git",
|
|
49
|
+
"directory": "plugin/langchain"
|
|
50
|
+
},
|
|
51
|
+
"egg": {
|
|
52
|
+
"typescript": true
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@eggjs/egg-module-common": "^3.65.2",
|
|
59
|
+
"@eggjs/mcp-client": "^3.65.2",
|
|
60
|
+
"@eggjs/tegg": "^3.65.2",
|
|
61
|
+
"@eggjs/tegg-common-util": "^3.65.2",
|
|
62
|
+
"@eggjs/tegg-langchain-decorator": "^3.65.2",
|
|
63
|
+
"@eggjs/tegg-lifecycle": "^3.65.2",
|
|
64
|
+
"@eggjs/tegg-loader": "^3.65.2",
|
|
65
|
+
"@eggjs/tegg-mcp-client": "^3.65.2",
|
|
66
|
+
"@eggjs/tegg-metadata": "^3.65.2",
|
|
67
|
+
"@eggjs/tegg-runtime": "^3.65.2",
|
|
68
|
+
"@langchain/community": "^1.0.0",
|
|
69
|
+
"@langchain/core": "^1.0.0",
|
|
70
|
+
"@langchain/langgraph": "^1.0.0",
|
|
71
|
+
"@langchain/mcp-adapters": "^1.0.0",
|
|
72
|
+
"@langchain/openai": "^1.0.0",
|
|
73
|
+
"@types/koa-router": "^7.0.40",
|
|
74
|
+
"koa-compose": "^3.2.1",
|
|
75
|
+
"langchain": "^1.0.0",
|
|
76
|
+
"sdk-base": "^4.2.0",
|
|
77
|
+
"urllib": "^4.4.0"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@eggjs/module-test-util": "^3.65.2",
|
|
81
|
+
"@eggjs/router": "^2.0.0",
|
|
82
|
+
"@eggjs/tegg-config": "^3.65.2",
|
|
83
|
+
"@eggjs/tegg-controller-plugin": "^3.65.2",
|
|
84
|
+
"@eggjs/tegg-plugin": "^3.65.2",
|
|
85
|
+
"@types/mocha": "^10.0.1",
|
|
86
|
+
"@types/node": "^20.2.4",
|
|
87
|
+
"cross-env": "^7.0.3",
|
|
88
|
+
"egg": "^3.9.1",
|
|
89
|
+
"egg-mock": "^5.5.0",
|
|
90
|
+
"egg-tracer": "^2.0.0",
|
|
91
|
+
"koa-router": "^8.0.8",
|
|
92
|
+
"mocha": "^10.2.0",
|
|
93
|
+
"mysql": "^2.18.1",
|
|
94
|
+
"ts-node": "^10.9.1",
|
|
95
|
+
"typescript": "^5.0.4"
|
|
96
|
+
},
|
|
97
|
+
"publishConfig": {
|
|
98
|
+
"access": "public"
|
|
99
|
+
},
|
|
100
|
+
"directories": {
|
|
101
|
+
"lib": "lib",
|
|
102
|
+
"test": "test"
|
|
103
|
+
},
|
|
104
|
+
"author": "",
|
|
105
|
+
"license": "ISC"
|
|
106
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { EggContainerFactory } from '@eggjs/tegg-runtime';
|
|
2
|
+
import { Type, Static } from '@eggjs/tegg/ajv';
|
|
3
|
+
import 'egg';
|
|
4
|
+
import '@eggjs/tegg-plugin/typings';
|
|
5
|
+
import '@eggjs/tegg-controller-plugin/typings';
|
|
6
|
+
import '@eggjs/tegg-mcp-client/typings';
|
|
7
|
+
|
|
8
|
+
export const ChatModelConfigModuleConfigSchema = Type.Object({
|
|
9
|
+
clients: Type.Record(Type.String(), Type.Object({
|
|
10
|
+
temperature: Type.Optional(Type.Number({
|
|
11
|
+
description: 'Sampling temperature to use',
|
|
12
|
+
})),
|
|
13
|
+
maxTokens: Type.Optional(Type.Number({
|
|
14
|
+
description: 'Maximum number of tokens to generate in the completion. -1 returns as many tokens as possible given the prompt and the model\'s maximum context size.',
|
|
15
|
+
})),
|
|
16
|
+
topP: Type.Optional(Type.Number({
|
|
17
|
+
description: 'Total probability mass of tokens to consider at each step',
|
|
18
|
+
})),
|
|
19
|
+
frequencyPenalty: Type.Optional(Type.Number({
|
|
20
|
+
description: 'Penalizes repeated tokens according to frequency',
|
|
21
|
+
})),
|
|
22
|
+
presencePenalty: Type.Optional(Type.Number({
|
|
23
|
+
description: 'Penalizes repeated tokens',
|
|
24
|
+
})),
|
|
25
|
+
n: Type.Optional(Type.Number({
|
|
26
|
+
description: 'Number of completions to generate for each prompt',
|
|
27
|
+
})),
|
|
28
|
+
logitBias: Type.Optional(Type.Record(Type.String(), Type.Number(), {
|
|
29
|
+
description: 'Dictionary used to adjust the probability of specific tokens being generated',
|
|
30
|
+
})),
|
|
31
|
+
user: Type.Optional(Type.String({
|
|
32
|
+
description: 'Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse.',
|
|
33
|
+
})),
|
|
34
|
+
streaming: Type.Optional(Type.Boolean({
|
|
35
|
+
description: 'Whether to stream the results or not. Enabling disables tokenUsage reporting',
|
|
36
|
+
})),
|
|
37
|
+
streamUsage: Type.Optional(Type.Boolean({
|
|
38
|
+
description: 'Whether or not to include token usage data in streamed chunks. @default true',
|
|
39
|
+
})),
|
|
40
|
+
modelName: Type.Optional(Type.String({
|
|
41
|
+
description: 'Model name to use, Alias for `model`',
|
|
42
|
+
})),
|
|
43
|
+
model: Type.Optional(Type.String({
|
|
44
|
+
description: 'Model name to use.',
|
|
45
|
+
})),
|
|
46
|
+
modelKwargs: Type.Optional(Type.Record(Type.String(), Type.Any(), {
|
|
47
|
+
description: 'Holds any additional parameters that are valid to pass to {@link https://platform.openai.com/docs/api-reference/completions/create | `openai.createCompletion`} that are not explicitly specified on this class.',
|
|
48
|
+
})),
|
|
49
|
+
/**
|
|
50
|
+
* List of stop words to use when generating. Alias for `stopSequences`
|
|
51
|
+
*/
|
|
52
|
+
stop: Type.Optional(Type.Array(Type.String(), {
|
|
53
|
+
description: 'List of stop words to use when generating. Alias for `stopSequences`',
|
|
54
|
+
})),
|
|
55
|
+
stopSequences: Type.Optional(Type.Array(Type.String(), {
|
|
56
|
+
description: 'List of stop words to use when generating.',
|
|
57
|
+
})),
|
|
58
|
+
timeout: Type.Optional(Type.Number({
|
|
59
|
+
description: 'Timeout to use when making requests to OpenAI.',
|
|
60
|
+
})),
|
|
61
|
+
/**
|
|
62
|
+
* API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable. Alias for `apiKey`
|
|
63
|
+
*/
|
|
64
|
+
openAIApiKey: Type.Optional(Type.String({
|
|
65
|
+
description: 'API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable. Alias for `apiKey`',
|
|
66
|
+
})),
|
|
67
|
+
apiKey: Type.Optional(Type.String({
|
|
68
|
+
description: 'API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable.',
|
|
69
|
+
})),
|
|
70
|
+
maxConcurrency: Type.Optional(Type.Number({
|
|
71
|
+
description: 'The maximum number of concurrent calls that can be made. Defaults to `Infinity`, which means no limit.',
|
|
72
|
+
})),
|
|
73
|
+
maxRetries: Type.Optional(Type.Number({
|
|
74
|
+
description: 'The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6.',
|
|
75
|
+
})),
|
|
76
|
+
verbose: Type.Optional(Type.Boolean({
|
|
77
|
+
description: 'debug option',
|
|
78
|
+
})),
|
|
79
|
+
tags: Type.Optional(Type.Array(Type.String())),
|
|
80
|
+
metadata: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
81
|
+
configuration: Type.Optional(Type.Object({
|
|
82
|
+
apiKey: Type.Optional(Type.String({
|
|
83
|
+
description: 'The OpenAI API key to use.',
|
|
84
|
+
})),
|
|
85
|
+
baseURL: Type.Optional(Type.String({
|
|
86
|
+
description: 'Override the default base URL for the API, e.g., "https://api.example.com/v2/"',
|
|
87
|
+
})),
|
|
88
|
+
timeout: Type.Optional(Type.Number({
|
|
89
|
+
description: 'The maximum amount of time (in milliseconds) that the client should wait for a response from the server before timing out a single request. Note that request timeouts are retried by default, so in a worst-case scenario you may wait much longer than this timeout before the promise succeeds or fails.',
|
|
90
|
+
})),
|
|
91
|
+
maxRetries: Type.Optional(Type.Number({
|
|
92
|
+
description: 'The maximum number of times that the client will retry a request in case of a temporary failure, like a network error or a 5XX error from the server.',
|
|
93
|
+
default: 2,
|
|
94
|
+
})),
|
|
95
|
+
defaultHeaders: Type.Optional(Type.Record(Type.String(), Type.Union([
|
|
96
|
+
Type.String(),
|
|
97
|
+
Type.Array(Type.String()),
|
|
98
|
+
]), {
|
|
99
|
+
description: 'Default headers to include with every request to the API. These can be removed in individual requests by explicitly setting the header to `undefined` or `null` in request options.',
|
|
100
|
+
})),
|
|
101
|
+
defaultQuery: Type.Optional(Type.Record(Type.String(), Type.String(), {
|
|
102
|
+
description: 'Default query parameters to include with every request to the API. These can be removed in individual requests by explicitly setting the param to `undefined` in request options.',
|
|
103
|
+
})),
|
|
104
|
+
})),
|
|
105
|
+
})),
|
|
106
|
+
}, {
|
|
107
|
+
title: 'ChatModel 设置',
|
|
108
|
+
name: 'ChatModel',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export type ChatModelConfigModuleConfigType = Static<typeof ChatModelConfigModuleConfigSchema>;
|
|
112
|
+
|
|
113
|
+
declare module '@eggjs/tegg' {
|
|
114
|
+
export type LangChainModuleConfig = {
|
|
115
|
+
ChatModel?: ChatModelConfigModuleConfigType;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export interface ModuleConfig extends LangChainModuleConfig {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare module 'egg' {
|
|
123
|
+
export interface ModuleConfigApplication {
|
|
124
|
+
moduleReferences: readonly ModuleReference[];
|
|
125
|
+
moduleConfigs: Record<string, ModuleConfigHolder>;
|
|
126
|
+
eggContainerFactory: typeof EggContainerFactory;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface Application extends ModuleConfigApplication {
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
}
|