feat(data):优化数据处理和模型结果展示(ps:今天白天太忙了,更新内容较少)

- 修改文本处理方法,提高消息内容的可读性
- 在 AIResponseResult模型中添加 modelName 字段
- 更新前端组件,展示模型名称信息
- 优化数据库查询,提高响应速度
This commit is contained in:
spark 2025-02-14 22:39:57 +08:00
parent f4da21d645
commit a20d4e721d
5 changed files with 12 additions and 4 deletions

View File

@ -105,7 +105,7 @@ func TestGetHtmlWithActions(t *testing.T) {
} }
var messages []string var messages []string
document.Find("div.finance-hover,div.list-date").Each(func(i int, selection *goquery.Selection) { document.Find("div.finance-hover,div.list-date").Each(func(i int, selection *goquery.Selection) {
text := strutil.RemoveNonPrintable(selection.Text()) text := strutil.RemoveWhiteSpace(selection.Text(), false)
messages = append(messages, text) messages = append(messages, text)
logger.SugaredLogger.Infof("搜索到消息-%s: %s", "", text) logger.SugaredLogger.Infof("搜索到消息-%s: %s", "", text)
}) })

View File

@ -356,7 +356,7 @@ func SearchGuShiTongStockInfo(stock string, crawlTimeOut int64) *[]string {
return &[]string{} return &[]string{}
} }
document.Find("div.finance-hover,div.list-date").Each(func(i int, selection *goquery.Selection) { document.Find("div.finance-hover,div.list-date").Each(func(i int, selection *goquery.Selection) {
text := strutil.RemoveNonPrintable(selection.Text()) text := strutil.RemoveWhiteSpace(selection.Text(), false)
messages = append(messages, text) messages = append(messages, text)
logger.SugaredLogger.Infof("SearchGuShiTongStockInfo搜索到消息-%s: %s", "", text) logger.SugaredLogger.Infof("SearchGuShiTongStockInfo搜索到消息-%s: %s", "", text)
}) })
@ -610,12 +610,13 @@ func (o OpenAi) SaveAIResponseResult(stockCode, stockName, result string) {
db.Dao.Create(&models.AIResponseResult{ db.Dao.Create(&models.AIResponseResult{
StockCode: stockCode, StockCode: stockCode,
StockName: stockName, StockName: stockName,
ModelName: o.Model,
Content: result, Content: result,
}) })
} }
func (o OpenAi) GetAIResponseResult(stock string) *models.AIResponseResult { func (o OpenAi) GetAIResponseResult(stock string) *models.AIResponseResult {
var result models.AIResponseResult var result models.AIResponseResult
db.Dao.Where("stock_code = ?", stock).Order("id desc").First(&result) db.Dao.Where("stock_code = ?", stock).Order("id desc").Limit(1).First(&result)
return &result return &result
} }

View File

@ -135,6 +135,7 @@ type Commit struct {
type AIResponseResult struct { type AIResponseResult struct {
gorm.Model gorm.Model
ModelName string `json:"modelName"`
StockCode string `json:"stockCode"` StockCode string `json:"stockCode"`
StockName string `json:"stockName"` StockName string `json:"stockName"`
Content string `json:"content"` Content string `json:"content"`

View File

@ -55,6 +55,7 @@ const formModel = ref({
}) })
const data = reactive({ const data = reactive({
modelName:"",
name: "", name: "",
code: "", code: "",
fenshiURL:"", fenshiURL:"",
@ -485,6 +486,7 @@ function SendMessage(result,type){
SendDingDingMessageByType(msg,result["股票代码"],type) SendDingDingMessageByType(msg,result["股票代码"],type)
} }
function aiReCheckStock(stock,stockCode) { function aiReCheckStock(stock,stockCode) {
data.modelName=""
data.airesult="" data.airesult=""
data.time="" data.time=""
data.name=stock data.name=stock
@ -500,6 +502,7 @@ function aiReCheckStock(stock,stockCode) {
function aiCheckStock(stock,stockCode){ function aiCheckStock(stock,stockCode){
GetAIResponseResult(stockCode).then(result => { GetAIResponseResult(stockCode).then(result => {
if(result.content){ if(result.content){
data.modelName=result.modelName
data.name=stock data.name=stock
data.code=stockCode data.code=stockCode
data.loading=false data.loading=false
@ -515,6 +518,7 @@ function aiCheckStock(stock,stockCode){
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
data.time=formattedDate data.time=formattedDate
}else{ }else{
data.modelName=""
data.airesult="" data.airesult=""
data.time="" data.time=""
data.name=stock data.name=stock
@ -743,7 +747,7 @@ function saveAsMarkdown() {
</template> </template>
<template #footer> <template #footer>
<n-flex justify="space-between"> <n-flex justify="space-between">
<n-text type="info" v-if="data.time" >分析时间:{{data.time}}</n-text> <n-text type="info" v-if="data.time" ><n-tag v-if="data.modelName" type="warning" round :bordered="false">{{data.modelName}}</n-tag>{{data.time}}</n-text>
<n-text type="error" >*AI分析结果仅供参考请以实际行情为准投资需谨慎风险自担</n-text> <n-text type="error" >*AI分析结果仅供参考请以实际行情为准投资需谨慎风险自担</n-text>
</n-flex> </n-flex>
</template> </template>

View File

@ -343,6 +343,7 @@ export namespace models {
UpdatedAt: any; UpdatedAt: any;
// Go type: gorm // Go type: gorm
DeletedAt: any; DeletedAt: any;
modelName: string;
stockCode: string; stockCode: string;
stockName: string; stockName: string;
content: string; content: string;
@ -358,6 +359,7 @@ export namespace models {
this.CreatedAt = this.convertValues(source["CreatedAt"], null); this.CreatedAt = this.convertValues(source["CreatedAt"], null);
this.UpdatedAt = this.convertValues(source["UpdatedAt"], null); this.UpdatedAt = this.convertValues(source["UpdatedAt"], null);
this.DeletedAt = this.convertValues(source["DeletedAt"], null); this.DeletedAt = this.convertValues(source["DeletedAt"], null);
this.modelName = source["modelName"];
this.stockCode = source["stockCode"]; this.stockCode = source["stockCode"];
this.stockName = source["stockName"]; this.stockName = source["stockName"];
this.content = source["content"]; this.content = source["content"];