This commit is contained in:
lik
2026-05-25 12:46:14 +08:00
parent 01d54cc580
commit 17014446ba
24 changed files with 5932 additions and 0 deletions

29
agent/task.js Normal file
View File

@@ -0,0 +1,29 @@
import EscortAgent from "./agent.js";
class ChatTask {
constructor(options = {}) {
this.options = {
modelProvider: options.modelProvider || "deepseek",
apiKey: options.apiKey,
baseURL: options.baseURL,
modelName: options.modelName,
temperature: options.temperature ?? 0.7,
maxIterations: options.maxIterations || 10,
};
this.agents = {};
}
async streamChat(userInfo, message, callback) {
const userId = userInfo ? userInfo._id : message.appId;
if (!this.agents[userId]) {
this.agents[userId] = new EscortAgent();
}
return this.agents[userId].streamChat(userInfo, [message], callback);
}
}
const chatTask = new ChatTask();
export { ChatTask, chatTask };
export default chatTask;