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

feat:政令增加AI智能报告

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