提交 1ad256dd authored 作者: 张烨's avatar 张烨

feat:政令增加AI智能报告

上级 3def5f9f
......@@ -83,6 +83,14 @@ export function getDecreeReport(params) {
export function getKeyWordUp() {
return request({
method: 'GET',
url: `/api/element//getKeyWordUp/2025-01-01`,
url: `/api/element/getKeyWordUp/2025-01-01`,
})
}
// 报告内容摘要
export function getOverview(params) {
return request({
method: 'GET',
url: `/api/administrativeOrderInfo/overview/${params.id}`,
})
}
\ No newline at end of file
......@@ -205,7 +205,7 @@
</div>
<div class="ai-pane">
<AiButton />
<AiPane aiContent="假数据假数据假数据假数据假数据假数据假数据假数据假数据假数据假数据" />
<AiPane :aiContent="summarize1" />
</div>
</div>
......@@ -238,7 +238,7 @@
</div>
<div class="ai-pane">
<AiButton />
<AiPane aiContent="假数据假数据假数据假数据假数据假数据假数据假数据假数据假数据假数据" />
<AiPane :aiContent="summarize2" />
</div>
</div>
</div>
......@@ -471,7 +471,6 @@ import {
getDecreehylyList,
getDecreeTypeList,
getKeyOrganization,
getChartInterpretation,
} from "@/api/decree/home";
import { getPersonSummaryInfo } from "@/api/common/index";
import { getNews, getSocialMedia } from "@/api/general/index";
......@@ -801,6 +800,7 @@ const box5Params = reactive({
domainId: '',
proposeName: '',
})
const summarize1 = ref()
const handleGetDecreeYearOrder = async () => {
try {
let { year, domainId, proposeName } = box5Params;
......@@ -817,7 +817,7 @@ const handleGetDecreeYearOrder = async () => {
chart1Data.value.dataY = res.data.map(item => {
return item.count;
});
onChartInterpretation({type:"柱状图",name:"数量变化趋势",data:res.data})
summarize1.value = await onChartInterpretation({type:"柱状图",name:"数量变化趋势",data:res.data})
}
} catch (error) {
console.error("行政令发布频度error", error);
......@@ -825,36 +825,37 @@ const handleGetDecreeYearOrder = async () => {
};
// AI智能总结
const onChartInterpretation = async (text) => {
try {
const res = await getChartInterpretation({text});
console.log("AI智能总结", res);
const reader = res.getReader();
const response = await fetch('/aiAnalysis/chart_interpretation', {
method: 'POST',
headers: {
"X-API-Key": "aircasKEY19491001",
'Content-Type': 'application/json',
},
body: JSON.stringify({text}) // 把参数转为JSON字符串
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let fullText = '';
let buffer = '';
let summarize = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
// 解析 chunk 中的 message 片段
const messages = chunk.split('\n\n').filter(Boolean);
for (const msg of messages) {
if (msg.startsWith('data: ')) {
const data = JSON.parse(msg.slice(6));
if (data.text) fullText += data.text;
try {
const result = JSON.parse(fullText);
renderToPage(result);
} catch (e) {}
}
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split('\n');
buffer = lines.pop() || '';
for (const line of lines) {
if (line.startsWith('data: ')) {
const content = line.substring(6);
const textMatch = content.match(/"解读":\s*"([^"]*)"/);
if (textMatch && textMatch[1]) summarize = textMatch[1];
}
}
console.log("fullText", fullText);
} catch (error) {
console.error("AI智能总结error", error);
}
return summarize
}
const handleBox5 = async () => {
......@@ -882,6 +883,7 @@ const box6Params = reactive({
year: yearList[0].value,
proposeName: '',
});
const summarize2 = ref()
const handleGetDecreeArea = async () => {
try {
let { year, proposeName } = box6Params;
......@@ -897,6 +899,7 @@ const handleGetDecreeArea = async () => {
value: item.count
};
});
summarize2.value = await onChartInterpretation({type:"环形图",name:"领域分布情况",data:res.data})
}
} catch (error) {
console.error("政令科技领域error", error);
......
......@@ -168,6 +168,7 @@ import {
getDecreeRiskSignal,
getDecreeIssueOrganization,
getKeyWordUp,
getOverview,
} from "@/api/decree/introduction";
import { getDecreeRelatedEvent } from "@/api/decree/background";
import AiSummary from '@/components/base/Ai/AiSummary/index.vue'
......@@ -243,16 +244,16 @@ const onKeyWordUp = async () => {
};
// 报告内容摘要
const box1Data = ref(`包括经济竞争在内的美中竞争自2017年以来一直在定义美国外交政策。这两个经济体是世界上第一和第二大国家经济体,并且深深交织在一起。改变关系,无论多么必要,可能是昂贵的。因此,美国面临着一项挑战,确保其经济在耦合的战略竞争条件下满足国家的需求。为了应对这一挑战,兰德大学的研究人员对美中竞争进行了经济和制度分析,进行了参与式的远见练习,以了解确保美国经济健康的长期路径,并创建了两个经济竞争游戏,探索多个国家在相互交流的同时确保经济健康的动态...`);
// const handleGetDecreeKeyInstruction = async () => {
// try {
// const res = await getDecreeKeyInstruction();
// console.log("报告内容摘要", res);
// box1Data.value = res.data;
// } catch (error) {
// console.error("获取报告内容摘要数据失败", error);
// }
// };
const box1Data = ref('');
const onOverview = async () => {
try {
const res = await getOverview({id: decreeId.value});
console.log("报告内容摘要", res);
box1Data.value = res.data;
} catch (error) {
console.error("获取报告内容摘要数据失败", error);
}
};
// 相关事件
const relatedData = ref([]);
......@@ -342,6 +343,7 @@ const handleClickUser = item => {
};
onMounted(() => {
onOverview()
onKeyWordUp()
onRiskSignalData()
handleGetRelateEvents();
......
......@@ -53,8 +53,9 @@ export default defineConfig({
rewrite: (path) => path.replace(/^\/reportData/, '')
},
'/api': {
// target: 'http://8.140.26.4:9085/',
target: 'http://192.168.0.4:28080/',
target: 'http://8.140.26.4:9085/',
// target: 'http://192.168.0.4:28080/',
// target: 'http://172.20.10.3:28080/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论