30 lines
763 B
JavaScript
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;
|