This commit is contained in:
lik
2026-05-25 12:34:16 +08:00
parent c614b19b78
commit 1e7aa55533
986 changed files with 23880 additions and 0 deletions

29
api/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;