diff --git a/backend/data/openai_api.go b/backend/data/openai_api.go
index 7cc0f36..e4f3dd4 100644
--- a/backend/data/openai_api.go
+++ b/backend/data/openai_api.go
@@ -33,6 +33,7 @@ type OpenAi struct {
TimeOut int `json:"time_out"`
QuestionTemplate string `json:"question_template"`
CrawlTimeOut int64 `json:"crawl_time_out"`
+ KDays int64 `json:"kDays"`
}
func NewDeepSeekOpenAi(ctx context.Context) *OpenAi {
@@ -44,6 +45,9 @@ func NewDeepSeekOpenAi(ctx context.Context) *OpenAi {
if config.CrawlTimeOut <= 0 {
config.CrawlTimeOut = 60
}
+ if config.KDays < 30 {
+ config.KDays = 30
+ }
}
return &OpenAi{
ctx: ctx,
@@ -56,6 +60,7 @@ func NewDeepSeekOpenAi(ctx context.Context) *OpenAi {
TimeOut: config.OpenAiApiTimeOut,
QuestionTemplate: config.QuestionTemplate,
CrawlTimeOut: config.CrawlTimeOut,
+ KDays: config.KDays,
}
}
@@ -146,7 +151,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[
go func() {
defer wg.Done()
endDate := time.Now().Format("20060102")
- startDate := time.Now().Add(-time.Hour * 24 * 365).Format("20060102")
+ startDate := time.Now().Add(-time.Hour * time.Duration(24*o.KDays)).Format("20060102")
K := NewTushareApi(getConfig()).GetDaily(ConvertStockCodeToTushareCode(stockCode), startDate, endDate, o.CrawlTimeOut)
msg = append(msg, map[string]interface{}{
"role": "assistant",
diff --git a/backend/data/settings_api.go b/backend/data/settings_api.go
index 71c1ca1..e8ad404 100644
--- a/backend/data/settings_api.go
+++ b/backend/data/settings_api.go
@@ -27,6 +27,7 @@ type Settings struct {
CheckUpdate bool `json:"checkUpdate"`
QuestionTemplate string `json:"questionTemplate"`
CrawlTimeOut int64 `json:"crawlTimeOut"`
+ KDays int64 `json:"kDays"`
}
func (receiver Settings) TableName() string {
@@ -65,6 +66,7 @@ func (s SettingsApi) UpdateConfig() string {
"open_ai_api_time_out": s.Config.OpenAiApiTimeOut,
"question_template": s.Config.QuestionTemplate,
"crawl_time_out": s.Config.CrawlTimeOut,
+ "k_days": s.Config.KDays,
})
} else {
logger.SugaredLogger.Infof("未找到配置,创建默认配置:%+v", s.Config)
@@ -86,6 +88,7 @@ func (s SettingsApi) UpdateConfig() string {
OpenAiApiTimeOut: s.Config.OpenAiApiTimeOut,
QuestionTemplate: s.Config.QuestionTemplate,
CrawlTimeOut: s.Config.CrawlTimeOut,
+ KDays: s.Config.KDays,
})
}
return "保存成功!"
@@ -93,6 +96,18 @@ func (s SettingsApi) UpdateConfig() string {
func (s SettingsApi) GetConfig() *Settings {
var settings Settings
db.Dao.Model(&Settings{}).First(&settings)
+
+ if settings.OpenAiEnable {
+ if settings.OpenAiApiTimeOut <= 0 {
+ settings.OpenAiApiTimeOut = 60 * 5
+ }
+ if settings.CrawlTimeOut <= 0 {
+ settings.CrawlTimeOut = 60
+ }
+ if settings.KDays < 30 {
+ settings.KDays = 30
+ }
+ }
return &settings
}
diff --git a/frontend/src/components/settings.vue b/frontend/src/components/settings.vue
index 10320a3..f25b75e 100644
--- a/frontend/src/components/settings.vue
+++ b/frontend/src/components/settings.vue
@@ -31,6 +31,7 @@ const formValue = ref({
timeout: 5,
questionTemplate: "{{stockName}}分析和总结",
crawlTimeOut:30,
+ kDays:30,
}
})
@@ -58,6 +59,7 @@ onMounted(()=>{
timeout:res.openAiApiTimeOut,
questionTemplate:res.questionTemplate?res.questionTemplate:'{{stockName}}分析和总结',
crawlTimeOut:res.crawlTimeOut,
+ kDays:res.kDays,
}
console.log(res)
})
@@ -84,6 +86,7 @@ function saveConfig(){
openAiApiTimeOut:formValue.value.openAI.timeout,
questionTemplate:formValue.value.openAI.questionTemplate,
crawlTimeOut:formValue.value.openAI.crawlTimeOut,
+ kDays:formValue.value.openAI.kDays
})
//console.log("Settings",config)
@@ -152,6 +155,7 @@ function importConfig(){
timeout:config.openAiApiTimeOut,
questionTemplate:config.questionTemplate,
crawlTimeOut:config.crawlTimeOut,
+ kDays:config.kDays
}
// formRef.value.resetFields()
};
@@ -240,9 +244,12 @@ window.onerror = function (event, source, lineno, colno, error) {
-
+
+
+
+
-