Files
ws_health/agent/escort/task.js
2026-05-25 12:34:16 +08:00

30 lines
763 B
JavaScript

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;