listpage-next-ai 0.0.210
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/cjs/index.d.ts +32 -0
- package/dist/cjs/index.js +141 -0
- package/package.json +48 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AgentExecutorInput } from '@langchain/classic/agents';
|
|
2
|
+
import { IterableReadableStream } from '@langchain/core/utils/stream';
|
|
3
|
+
import { StreamEvent } from '@langchain/core/tracers/log_stream';
|
|
4
|
+
|
|
5
|
+
export declare class Agent {
|
|
6
|
+
system_prompt: string;
|
|
7
|
+
model: string;
|
|
8
|
+
model_config: Record<string, any>;
|
|
9
|
+
tools: AgentExecutorInput['tools'];
|
|
10
|
+
api_key: string;
|
|
11
|
+
constructor(options: AgentOptions);
|
|
12
|
+
stream(sessionId: string, input: string, chat_history: MessageData[]): Promise<IterableReadableStream<StreamEvent>>;
|
|
13
|
+
private createRunnable;
|
|
14
|
+
private createExecutor;
|
|
15
|
+
private createPrompt;
|
|
16
|
+
private createModel;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare interface AgentOptions {
|
|
20
|
+
system_prompt: string;
|
|
21
|
+
tools: AgentExecutorInput['tools'];
|
|
22
|
+
model: string;
|
|
23
|
+
api_key: string;
|
|
24
|
+
model_config?: Record<string, any>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare interface MessageData {
|
|
28
|
+
role: 'user' | 'assistant';
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { }
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
Agent: ()=>Agent
|
|
28
|
+
});
|
|
29
|
+
const agents_namespaceObject = require("@langchain/classic/agents");
|
|
30
|
+
const prompts_namespaceObject = require("@langchain/core/prompts");
|
|
31
|
+
const openai_namespaceObject = require("@langchain/openai");
|
|
32
|
+
class ChatVolcengine extends openai_namespaceObject.ChatOpenAICompletions {
|
|
33
|
+
static lc_name() {
|
|
34
|
+
return 'ChatVolcengine';
|
|
35
|
+
}
|
|
36
|
+
_llmType() {
|
|
37
|
+
return 'volcengine';
|
|
38
|
+
}
|
|
39
|
+
constructor(fields){
|
|
40
|
+
super({
|
|
41
|
+
...fields,
|
|
42
|
+
configuration: {
|
|
43
|
+
baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
|
|
44
|
+
...fields?.configuration
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
_convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole) {
|
|
49
|
+
const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
|
|
50
|
+
messageChunk.additional_kwargs.reasoning_content = delta.reasoning_content;
|
|
51
|
+
return messageChunk;
|
|
52
|
+
}
|
|
53
|
+
_convertCompletionsMessageToBaseMessage(message, rawResponse) {
|
|
54
|
+
const langChainMessage = super._convertCompletionsMessageToBaseMessage(message, rawResponse);
|
|
55
|
+
langChainMessage.additional_kwargs.reasoning_content = message.reasoning_content;
|
|
56
|
+
return langChainMessage;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const runnables_namespaceObject = require("@langchain/core/runnables");
|
|
60
|
+
const chat_history_namespaceObject = require("@langchain/core/chat_history");
|
|
61
|
+
class Agent {
|
|
62
|
+
constructor(options){
|
|
63
|
+
this.system_prompt = options.system_prompt;
|
|
64
|
+
this.model = options.model;
|
|
65
|
+
this.tools = options.tools;
|
|
66
|
+
this.api_key = options.api_key;
|
|
67
|
+
this.model_config = options.model_config || {};
|
|
68
|
+
}
|
|
69
|
+
async stream(sessionId, input, chat_history) {
|
|
70
|
+
const runnable = await this.createRunnable(chat_history);
|
|
71
|
+
return runnable.streamEvents({
|
|
72
|
+
input
|
|
73
|
+
}, {
|
|
74
|
+
version: 'v2',
|
|
75
|
+
configurable: {
|
|
76
|
+
sessionId
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async createRunnable(messages) {
|
|
81
|
+
const executor = this.createExecutor();
|
|
82
|
+
const runnable = new runnables_namespaceObject.RunnableWithMessageHistory({
|
|
83
|
+
getMessageHistory: async ()=>{
|
|
84
|
+
const msg = new chat_history_namespaceObject.InMemoryChatMessageHistory();
|
|
85
|
+
messages.forEach((m)=>{
|
|
86
|
+
if ('user' === m.role) msg.addUserMessage(m.content);
|
|
87
|
+
else if ('assistant' === m.role) msg.addAIMessage(m.content);
|
|
88
|
+
});
|
|
89
|
+
return msg;
|
|
90
|
+
},
|
|
91
|
+
runnable: executor,
|
|
92
|
+
inputMessagesKey: 'input',
|
|
93
|
+
historyMessagesKey: 'chat_history'
|
|
94
|
+
});
|
|
95
|
+
return runnable;
|
|
96
|
+
}
|
|
97
|
+
createExecutor() {
|
|
98
|
+
const llm = this.createModel();
|
|
99
|
+
const prompt = this.createPrompt();
|
|
100
|
+
const agent = (0, agents_namespaceObject.createToolCallingAgent)({
|
|
101
|
+
llm: llm,
|
|
102
|
+
tools: this.tools,
|
|
103
|
+
prompt,
|
|
104
|
+
streamRunnable: true
|
|
105
|
+
});
|
|
106
|
+
return new agents_namespaceObject.AgentExecutor({
|
|
107
|
+
agent,
|
|
108
|
+
tools: this.tools
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
createPrompt() {
|
|
112
|
+
return prompts_namespaceObject.ChatPromptTemplate.fromMessages([
|
|
113
|
+
[
|
|
114
|
+
'system',
|
|
115
|
+
this.system_prompt
|
|
116
|
+
],
|
|
117
|
+
new prompts_namespaceObject.MessagesPlaceholder('chat_history'),
|
|
118
|
+
[
|
|
119
|
+
'human',
|
|
120
|
+
'{input}'
|
|
121
|
+
],
|
|
122
|
+
new prompts_namespaceObject.MessagesPlaceholder('agent_scratchpad')
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
createModel() {
|
|
126
|
+
return new ChatVolcengine({
|
|
127
|
+
apiKey: this.api_key,
|
|
128
|
+
model: this.model,
|
|
129
|
+
temperature: 0,
|
|
130
|
+
streaming: true,
|
|
131
|
+
...this.model_config
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.Agent = __webpack_exports__.Agent;
|
|
136
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
137
|
+
"Agent"
|
|
138
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
139
|
+
Object.defineProperty(exports, '__esModule', {
|
|
140
|
+
value: true
|
|
141
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "listpage-next-ai",
|
|
3
|
+
"version": "0.0.210",
|
|
4
|
+
"description": "A React component library for creating filter forms with Ant Design",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/cjs/index.d.ts",
|
|
10
|
+
"require": "./dist/cjs/index.js",
|
|
11
|
+
"import": "./dist/esm/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/cjs/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"nestjs"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rslib build",
|
|
24
|
+
"format": "prettier --write .",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
|
+
"test": "npx ts-node ./src/test.ts"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rsbuild/core": "^1.5.7",
|
|
30
|
+
"@rsbuild/plugin-react": "^1.4.0",
|
|
31
|
+
"@rslib/core": "^0.13.3",
|
|
32
|
+
"prettier": "^3.6.2",
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"ts-node": "~10.9.2",
|
|
35
|
+
"@types/lodash": "~4.17.20",
|
|
36
|
+
"@microsoft/api-extractor": "~7.53.3"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"uuid": "9.0.1",
|
|
40
|
+
"lodash": "~4.17.21",
|
|
41
|
+
"@langchain/core": "1.0.5",
|
|
42
|
+
"@langchain/community": "~1.0.3",
|
|
43
|
+
"@langchain/openai": "~1.1.1",
|
|
44
|
+
"@langchain/classic": "~1.0.3",
|
|
45
|
+
"rxjs": "~7.8.2",
|
|
46
|
+
"zod": "^3.23.8"
|
|
47
|
+
}
|
|
48
|
+
}
|