|
@@ -11,6 +11,7 @@ class AIService {
|
|
|
// 使用默认API密钥
|
|
|
this.apiKey = CONFIG.AI_API.DEFAULT_API_KEY;
|
|
|
this.controller = null; // 用于中断请求的 AbortController
|
|
|
+ this.currentPageInfo = null; // 保存当前页面信息
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -97,6 +98,11 @@ class AIService {
|
|
|
content: msg.content,
|
|
|
}));
|
|
|
|
|
|
+ // 如果存在页面信息,添加到当前消息的上下文
|
|
|
+ if (this.currentPageInfo) {
|
|
|
+ currentMessage = `基于之前总结的页面内容(标题:${this.currentPageInfo.title}),${currentMessage}`;
|
|
|
+ }
|
|
|
+
|
|
|
messages.push({
|
|
|
role: "user",
|
|
|
content: currentMessage,
|
|
@@ -180,6 +186,14 @@ ${pageInfo.mainContent}
|
|
|
setExcelData(data) {
|
|
|
this.currentExcelData = data;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置当前页面信息
|
|
|
+ * @param {Object} pageInfo 页面信息
|
|
|
+ */
|
|
|
+ setPageInfo(pageInfo) {
|
|
|
+ this.currentPageInfo = pageInfo;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 确保在DOM加载完成后再创建实例
|