Browse Source

情绪大模型、夺宝奇兵大模型新增思考过程;情绪大模型去除等待框;修改图表顺序展示的逻辑;解码器页面拉伸修复;

master
宋杰 1 week ago
parent
commit
2cf7f8190d
  1. 122
      src/views/AIchat.vue
  2. 296
      src/views/AiEmotion.vue
  3. 8
      src/views/components/emotionDecod.vue

122
src/views/AIchat.vue

@ -682,6 +682,104 @@ const addTypingTask = (message, content, speed) => {
processTypingQueue();
};
//
async function showThinkingProcess(stockName = null) {
//
const thinkingMessage1 = reactive({
sender: 'ai',
class: 'ing',
type: 'ing',
flag: true,
content: '正在思考......'
});
chatStore.messages.push(thinkingMessage1);
await new Promise(resolve => setTimeout(resolve, 1500));
chatStore.messages.pop();
//
const thinkingMessage2 = reactive({
sender: 'ai',
class: 'ing',
type: 'ing',
flag: true,
content: '正在解析关键数据......'
});
chatStore.messages.push(thinkingMessage2);
//
if (!stockName) {
return thinkingMessage2; // 便
}
//
await new Promise(resolve => setTimeout(resolve, 1500));
chatStore.messages.pop();
//
const thinkingMessage3 = reactive({
sender: 'ai',
class: 'ing',
type: 'ing',
flag: true,
content: `正在生成${stockName}全景作战报告......`
});
chatStore.messages.push(thinkingMessage3);
await new Promise(resolve => setTimeout(resolve, 1500));
chatStore.messages.pop();
//
const thinkingMessage4 = reactive({
sender: 'ai',
class: 'ing',
type: 'ing',
flag: true,
content: '报告已生成!'
});
chatStore.messages.push(thinkingMessage4);
await new Promise(resolve => setTimeout(resolve, 1500));
chatStore.messages.pop();
return null;
}
//
async function continueThinkingProcess(thinkingMessageRef, stockName) {
if (!thinkingMessageRef || !stockName) return;
//
await new Promise(resolve => setTimeout(resolve, 1500));
//
const index = chatStore.messages.indexOf(thinkingMessageRef);
if (index > -1) {
chatStore.messages.splice(index, 1);
}
//
const thinkingMessage3 = reactive({
sender: 'ai',
class: 'ing',
type: 'ing',
flag: true,
content: `正在生成${stockName}全景作战报告......`
});
chatStore.messages.push(thinkingMessage3);
await new Promise(resolve => setTimeout(resolve, 1500));
chatStore.messages.pop();
//
const thinkingMessage4 = reactive({
sender: 'ai',
class: 'ing',
type: 'ing',
flag: true,
content: '报告已生成!'
});
chatStore.messages.push(thinkingMessage4);
await new Promise(resolve => setTimeout(resolve, 1500));
chatStore.messages.pop();
}
const hasValidData = ref(false);
//
@ -724,6 +822,9 @@ watch(
//
let flag = true;
const codeData = ref();
//
const thinkingMessageRef = await showThinkingProcess();
// ,
try {
//
@ -732,6 +833,11 @@ watch(
console.log(codeData.value, "codeData");
//
if (result.code == 200) {
//
if (thinkingMessageRef && codeData.value.name) {
await continueThinkingProcess(thinkingMessageRef, codeData.value.name);
}
chatStore.messages.push({
class: "ing",
type: "ing",
@ -739,6 +845,14 @@ watch(
content: result.data.kaishi,
});
} else {
//
if (thinkingMessageRef) {
const index = chatStore.messages.indexOf(thinkingMessageRef);
if (index > -1) {
chatStore.messages.splice(index, 1);
}
}
flag = false;
console.log("执行回绝话术");
const AIcontent = ref(result.msg);
@ -770,6 +884,14 @@ watch(
emit('enableInput');
}
} catch (e) {
//
if (thinkingMessageRef) {
const index = chatStore.messages.indexOf(thinkingMessageRef);
if (index > -1) {
chatStore.messages.splice(index, 1);
}
}
console.log(e, "意图识别失败");
chatStore.messages.push({
class: "ing",

296
src/views/AiEmotion.vue

@ -42,9 +42,6 @@
</div>
<!-- 股票标签页 -->
<StockTabs />
<!-- 渲染整个页面 -->
<div v-if="isPageLoaded" class="main">
<div class="main-content-wrapper">
@ -299,7 +296,7 @@ defineExpose({
clearConversations
});
const isPageLoaded = ref(false); //
const isLoading = ref(false); //
// const isLoading = ref(false); //
const isRotating = ref(false);//
const version1 = ref(1); //
const conclusionData = ref(''); //
@ -970,6 +967,83 @@ function startImageRotation() {
}
//
async function showThinkingProcess(stockName = null) {
//
const thinkingMessage1 = reactive({ sender: 'ai', text: '正在思考......' });
messages.value.push(thinkingMessage1);
await new Promise(resolve => setTimeout(resolve, 1500));
messages.value.pop();
//
const thinkingMessage2 = reactive({ sender: 'ai', text: '正在解析关键数据......' });
messages.value.push(thinkingMessage2);
//
if (!stockName) {
return thinkingMessage2; // 便
}
//
await new Promise(resolve => setTimeout(resolve, 1500));
messages.value.pop();
//
const thinkingMessage3 = reactive({ sender: 'ai', text: `正在生成${stockName}量子四维矩阵图......` });
messages.value.push(thinkingMessage3);
await new Promise(resolve => setTimeout(resolve, 1500));
messages.value.pop();
//
const thinkingMessage4 = reactive({ sender: 'ai', text: '报告已生成!' });
messages.value.push(thinkingMessage4);
await new Promise(resolve => setTimeout(resolve, 1500));
messages.value.pop();
return null;
}
//
async function continueThinkingProcess(thinkingMessageRef, stockName) {
if (!thinkingMessageRef || !stockName) return;
//
await new Promise(resolve => setTimeout(resolve, 1500));
//
const index = messages.value.indexOf(thinkingMessageRef);
if (index > -1) {
messages.value.splice(index, 1);
}
//
const thinkingMessage3 = reactive({ sender: 'ai', text: `正在生成${stockName}量子四维矩阵图......` });
messages.value.push(thinkingMessage3);
// 便
return thinkingMessage3;
}
//
async function finishThinkingProcess(thinkingMessage3Ref) {
if (!thinkingMessage3Ref) return;
//
await new Promise(resolve => setTimeout(resolve, 1500));
//
const index = messages.value.indexOf(thinkingMessage3Ref);
if (index > -1) {
messages.value.splice(index, 1);
}
//
const thinkingMessage4 = reactive({ sender: 'ai', text: '报告已生成!' });
messages.value.push(thinkingMessage4);
await new Promise(resolve => setTimeout(resolve, 1500));
messages.value.pop();
}
//
async function handleSendMessage(input, onComplete) {
console.log("发送内容:", input);
@ -1052,6 +1126,9 @@ async function handleSendMessage(input, onComplete) {
timestamp: new Date().toISOString()
});
//
const thinkingMessageRef = await showThinkingProcess();
try {
//
const params = {
@ -1084,8 +1161,16 @@ async function handleSendMessage(input, onComplete) {
//
if (!parsedData || !parsedData.market || !parsedData.code) {
// refuse
isLoading.value = false;
//
if (thinkingMessageRef) {
const index = messages.value.indexOf(thinkingMessageRef);
if (index > -1) {
messages.value.splice(index, 1);
}
}
// refuse
// isLoading.value = false;
isPageLoaded.value = false;
const aiMessage = reactive({ sender: 'ai', text: processRefuseMessage(parsedData.refuse) });
messages.value.push(aiMessage);
@ -1108,8 +1193,14 @@ async function handleSendMessage(input, onComplete) {
}
//
//
let thinkingMessage3Ref = null;
if (thinkingMessageRef && parsedData.name) {
thinkingMessage3Ref = await continueThinkingProcess(thinkingMessageRef, parsedData.name);
}
//
isLoading.value = true;
// isLoading.value = true;
isPageLoaded.value = false;
@ -1135,13 +1226,18 @@ async function handleSendMessage(input, onComplete) {
//
if (conclusionResponse && conclusionResponse.data && fetchDataResult) {
//
if (thinkingMessage3Ref) {
await finishThinkingProcess(thinkingMessage3Ref);
}
// store
conclusionData.value = conclusionResponse.data;
// store
emotionStore.updateActiveStockConclusion(conclusionResponse.data);
//
isLoading.value = false;
// isLoading.value = false;
isPageLoaded.value = true;
//
@ -1184,8 +1280,16 @@ async function handleSendMessage(input, onComplete) {
}
});
} else {
//
if (thinkingMessage3Ref) {
const index = messages.value.indexOf(thinkingMessage3Ref);
if (index > -1) {
messages.value.splice(index, 1);
}
}
//
isLoading.value = false;
// isLoading.value = false;
// fetchDataResult false fetchData messages
// conclusionResponse
if (!conclusionResponse || !conclusionResponse.data) {
@ -1212,8 +1316,16 @@ async function handleSendMessage(input, onComplete) {
return;
}
} catch (error) {
//
if (thinkingMessage3Ref) {
const index = messages.value.indexOf(thinkingMessage3Ref);
if (index > -1) {
messages.value.splice(index, 1);
}
}
//
isLoading.value = false;
// isLoading.value = false;
// false
if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
@ -1298,7 +1410,7 @@ async function fetchData(code, market, stockName, queryText) {
if (!validation.isValid) {
console.log('API返回数据不完整,缺失字段:', validation.missingFields);
//
isLoading.value = false;
// isLoading.value = false;
// false
if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
@ -1345,7 +1457,7 @@ async function fetchData(code, market, stockName, queryText) {
return true; //
} else {
//
isLoading.value = false;
// isLoading.value = false;
// false
if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
@ -1373,7 +1485,7 @@ async function fetchData(code, market, stockName, queryText) {
}
} catch (error) {
//
isLoading.value = false;
// isLoading.value = false;
// false
if (emotionStore.stockList.length > 0 && emotionStore.activeStock) {
@ -1468,6 +1580,69 @@ function hasValidData(obj) {
return false;
}
//
async function renderChartsSequentially(clonedData) {
console.log('开始依次渲染图表');
//
const chartConfigs = [
{
name: '股市温度计',
ref: marketTemperatureRef,
visibility: chartVisibility.value.marketTemperature,
method: 'initChart',
params: [clonedData.GSWDJ, clonedData.KLine20, clonedData.WDRL]
},
{
name: '情绪解码器',
ref: emotionDecodRef,
visibility: chartVisibility.value.emotionDecod,
method: 'initQXNLZHEcharts',
params: [clonedData.KLine20, clonedData.QXJMQ]
},
{
name: '情绪探底雷达',
ref: emotionalBottomRadarRef,
visibility: chartVisibility.value.emotionalBottomRadar,
method: 'initEmotionalBottomRadar',
params: [clonedData.KLine20, clonedData.QXTDLD]
},
{
name: '情绪能量转化器',
ref: emoEnergyConverterRef,
visibility: chartVisibility.value.emoEnergyConverter,
method: 'initQXNLZHEcharts',
params: [clonedData.KLine20, clonedData.QXNLZHQ]
}
];
//
for (const config of chartConfigs) {
if (config.ref.value && config.visibility) {
console.log(`开始渲染${config.name}图表`);
console.log(`${config.name}Ref方法:`, typeof config.ref.value[config.method]);
if (typeof config.ref.value[config.method] === 'function') {
try {
config.ref.value[config.method](...config.params);
console.log(`${config.name}图表渲染成功`);
//
await new Promise(resolve => setTimeout(resolve, 800));
} catch (error) {
console.error(`${config.name}图表渲染失败:`, error);
}
} else {
console.error(`${config.name}Ref.${config.method} 方法不存在`);
}
} else {
console.log(`${config.name}图表未渲染,ref存在:`, !!config.ref.value, '数据存在:', config.visibility);
}
}
console.log('所有图表依次渲染完成');
}
//
function renderCharts(data) {
console.log('开始渲染图表,数据:', data);
@ -1496,7 +1671,7 @@ function renderCharts(data) {
//
isPageLoaded.value = false;
isLoading.value = false;
// isLoading.value = false;
return; //
}
@ -1549,80 +1724,8 @@ function renderCharts(data) {
}
}, 1000);
//
if (marketTemperatureRef.value && chartVisibility.value.marketTemperature) {
console.log('开始渲染股市温度计图表');
console.log('marketTemperatureRef方法:', typeof marketTemperatureRef.value.initChart);
if (typeof marketTemperatureRef.value.initChart === 'function') {
try {
marketTemperatureRef.value.initChart(clonedData.GSWDJ, clonedData.KLine20, clonedData.WDRL);
console.log('股市温度计图表渲染成功');
} catch (error) {
console.error('股市温度计图表渲染失败:', error);
}
} else {
console.error('marketTemperatureRef.initChart 方法不存在');
}
} else {
console.log('股市温度计图表未渲染,ref存在:', !!marketTemperatureRef.value, '数据存在:', chartVisibility.value.marketTemperature);
}
//
if (emotionDecodRef.value && chartVisibility.value.emotionDecod) {
console.log('开始渲染情绪解码器图表');
console.log('emotionDecodRef方法:', typeof emotionDecodRef.value.initQXNLZHEcharts);
if (typeof emotionDecodRef.value.initQXNLZHEcharts === 'function') {
try {
emotionDecodRef.value.initQXNLZHEcharts(clonedData.KLine20, clonedData.QXJMQ);
console.log('情绪解码器图表渲染成功');
} catch (error) {
console.error('情绪解码器图表渲染失败:', error);
}
} else {
console.error('emotionDecodRef.initQXNLZHEcharts 方法不存在');
}
} else {
console.log('情绪解码器图表未渲染,ref存在:', !!emotionDecodRef.value, '数据存在:', chartVisibility.value.emotionDecod);
}
//
if (emotionalBottomRadarRef.value && chartVisibility.value.emotionalBottomRadar) {
console.log('开始渲染情绪探底雷达图表');
console.log('emotionalBottomRadarRef方法:', typeof emotionalBottomRadarRef.value.initEmotionalBottomRadar);
if (typeof emotionalBottomRadarRef.value.initEmotionalBottomRadar === 'function') {
try {
emotionalBottomRadarRef.value.initEmotionalBottomRadar(
clonedData.KLine20,
clonedData.QXTDLD
);
console.log('情绪探底雷达图表渲染成功');
} catch (error) {
console.error('情绪探底雷达图表渲染失败:', error);
}
} else {
console.error('emotionalBottomRadarRef.initEmotionalBottomRadar 方法不存在');
}
} else {
console.log('情绪探底雷达图表未渲染,ref存在:', !!emotionalBottomRadarRef.value, '数据存在:', chartVisibility.value.emotionalBottomRadar);
}
//
if (emoEnergyConverterRef.value && chartVisibility.value.emoEnergyConverter) {
console.log('开始渲染情绪能量转化器图表');
console.log('emoEnergyConverterRef方法:', typeof emoEnergyConverterRef.value.initQXNLZHEcharts);
if (typeof emoEnergyConverterRef.value.initQXNLZHEcharts === 'function') {
try {
emoEnergyConverterRef.value.initQXNLZHEcharts(clonedData.KLine20, clonedData.QXNLZHQ);
console.log('情绪能量转化器图表渲染成功');
} catch (error) {
console.error('情绪能量转化器图表渲染失败:', error);
}
} else {
console.error('emoEnergyConverterRef.initQXNLZHEcharts 方法不存在');
}
} else {
console.log('情绪能量转化器图表未渲染,ref存在:', !!emoEnergyConverterRef.value, '数据存在:', chartVisibility.value.emoEnergyConverter);
}
//
renderChartsSequentially(clonedData);
console.log('图表渲染完成');
} catch (error) {
@ -3212,24 +3315,24 @@ const emit = defineEmits(['updateMessage', 'sendMessage', 'ensureAIchat']);
}
/* 加载提示样式 */
.loading-container {
/* .loading-container {
display: flex;
justify-content: center;
align-items: center;
min-height: 20vh;
padding: 20px 10px;
}
} */
.loading-content {
/* .loading-content {
text-align: center;
background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(0, 100, 200, 0.15) 100%);
border: 2px solid rgba(0, 212, 255, 0.4);
border-radius: 20px;
padding: 40px;
box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
}
} */
.loading-spinner {
/* .loading-spinner {
width: 60px;
height: 60px;
border: 4px solid rgba(0, 212, 255, 0.3);
@ -3237,7 +3340,7 @@ const emit = defineEmits(['updateMessage', 'sendMessage', 'ensureAIchat']);
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}
} */
@keyframes spin {
0% {
@ -3249,13 +3352,13 @@ const emit = defineEmits(['updateMessage', 'sendMessage', 'ensureAIchat']);
}
}
.loading-text {
/* .loading-text {
color: #00d4ff;
font-size: 18px;
font-weight: bold;
text-shadow: 0 2px 8px rgba(0, 212, 255, 0.5);
letter-spacing: 1px;
}
} */
/* 顶部锚点样式 */
.top-anchor {
@ -3283,7 +3386,6 @@ const emit = defineEmits(['updateMessage', 'sendMessage', 'ensureAIchat']);
align-items: center !important;
justify-content: center !important;
cursor: pointer !important;
box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3) !important;
transition: all 0.3s ease !important;
z-index: 100 !important;
color: white !important;

8
src/views/components/emotionDecod.vue

@ -93,8 +93,10 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
top: "5%",
height: window.innerWidth <= 768 ? "30%" : "40%"
},
{ top: "45%", height: "35%" },
{ top: "80%", height: "2%" },
{ top: window.innerWidth <= 768 ? "35%" :"45%",
height: "35%" },
{ top: window.innerWidth <= 768 ? "70%" : "80%",
height: "2%" },
],
visualMap: [
@ -278,7 +280,7 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
shadowOffsetX: 2,
shadowOffsetY: 2,
},
bottom: window.innerWidth > 768 ? "8%" : "5%", //
bottom: "8%", //
},
{
show: !1,

Loading…
Cancel
Save