43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package rule
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"git.apinb.com/bsm-sdk/core/utils"
|
||
"git.apinb.com/quant/gostock/internal/config"
|
||
"git.apinb.com/quant/gostock/internal/logic/deepseek"
|
||
)
|
||
|
||
var (
|
||
MarkdataPath = "./markdata/"
|
||
)
|
||
|
||
func (r *RuleFactory) RunAi(code string) {
|
||
mdPath := MarkdataPath + code + ".md"
|
||
if !utils.PathExists(mdPath) {
|
||
r.Model.AiScrore = -1
|
||
r.Model.AddDesc(fmt.Sprintf("%s markdown 文件未找友", mdPath))
|
||
return
|
||
}
|
||
|
||
c := deepseek.Config{
|
||
APIKey: config.Spec.DeepSeekApiKey, // 替换为你的API Key
|
||
BaseURL: "https://api.deepseek.com",
|
||
Model: "deepseek-chat", // 或 "deepseek-coder"
|
||
MaxTokens: 2000,
|
||
Temperature: 0.7,
|
||
}
|
||
|
||
prompt := "你是一名资深量化投研分析师。请根据markdown格式的附件内容,给出详细总结与买入评分(0-10),输出JSON,字段:summary(500字内中文总结)、score(0-10数字)、action(买入/谨慎/观望)、risk(一句风险提示)。"
|
||
result, err := deepseek.ProcessMarkdownQA(c, mdPath, prompt)
|
||
if err != nil {
|
||
r.Model.AiScrore = -1
|
||
r.Model.AddDesc(fmt.Sprintf("处理失败: %v", err))
|
||
return
|
||
}
|
||
|
||
// 输出JSON格式的结果
|
||
fmt.Println(string(result))
|
||
|
||
}
|