diff --git a/app.go b/app.go index 7041a5c..faf10c0 100644 --- a/app.go +++ b/app.go @@ -1134,13 +1134,13 @@ func (a *App) SummaryStockNews(question string, sysPromptId *int) { Type: "function", Function: data.ToolFunction{ Name: "SearchStockByIndicators", - Description: "按行业根据选股指标或策略,返回符合指标或策略的股票列表。多个行业的筛选需按行业顺序调用多次,不支持并行调用", + Description: "根据自然语言筛选股票,返回自然语言选股条件要求的股票所有相关数据。单独输入股票名称可以获取当前股票最新的股价交易数据和基础财务指标信息", Parameters: data.FunctionParameters{ Type: "object", Properties: map[string]any{ "words": map[string]any{ "type": "string", - "description": "行业选股指标或策略,并且条件使用;分隔,或者条件使用,分隔。例如:创新药;PE<30;净利润增长率>50%;", + "description": "选股自然语言,并且条件使用;分隔,或者条件使用,分隔。例1:创新药;PE<30;净利润增长率>50%。 例2:上证指数(指数名称)。 例3:长电科技(股票名称)", }, }, Required: []string{"words"}, diff --git a/backend/data/openai_api.go b/backend/data/openai_api.go index e1e8689..f486d6a 100644 --- a/backend/data/openai_api.go +++ b/backend/data/openai_api.go @@ -766,10 +766,14 @@ func AskAi(o OpenAi, err error, messages []map[string]interface{}, ch chan map[s res := &models.Resp{} if err := json.Unmarshal([]byte(line), res); err == nil { //ch <- line + msg := res.Message + if res.Error.Message != "" { + msg = res.Error.Message + } ch <- map[string]any{ "code": 0, "question": question, - "content": res.Message, + "content": msg, } } } @@ -920,10 +924,10 @@ func AskAiWithTools(o OpenAi, err error, messages []map[string]interface{}, ch c logger.SugaredLogger.Infof("SearchStockByIndicators:words:%s --> %s", words, content) - messages = append(messages, map[string]interface{}{ - "role": "assistant", - "content": currentAIContent.String(), - }) + //messages = append(messages, map[string]interface{}{ + // "role": "assistant", + // "content": currentAIContent.String(), + //}) messages = append(messages, map[string]interface{}{ "role": "tool", "content": content, @@ -964,10 +968,14 @@ func AskAiWithTools(o OpenAi, err error, messages []map[string]interface{}, ch c res := &models.Resp{} if err := json.Unmarshal([]byte(line), res); err == nil { //ch <- line + msg := res.Message + if res.Error.Message != "" { + msg = res.Error.Message + } ch <- map[string]any{ "code": 0, "question": question, - "content": res.Message, + "content": msg, } } } diff --git a/backend/data/openai_api_test.go b/backend/data/openai_api_test.go index 3856425..8c97c6d 100644 --- a/backend/data/openai_api_test.go +++ b/backend/data/openai_api_test.go @@ -14,13 +14,13 @@ func TestNewDeepSeekOpenAiConfig(t *testing.T) { Type: "function", Function: ToolFunction{ Name: "SearchStockByIndicators", - Description: "通过解析自然语言,形成选股指标或策略,返回符合指标或策略的股票列表", + Description: "根据自然语言筛选股票,返回自然语言选股条件要求的股票所有相关数据", Parameters: FunctionParameters{ Type: "object", Properties: map[string]any{ "words": map[string]any{ "type": "string", - "description": "选股指标或策略的自然语言", + "description": "选股自然语言,并且条件使用;分隔,或者条件使用,分隔。例如:创新药;PE<30;净利润增长率>50%;", }, }, Required: []string{"words"}, @@ -35,7 +35,9 @@ func TestNewDeepSeekOpenAiConfig(t *testing.T) { for { select { case msg := <-res: - t.Log(msg) + if len(msg) > 0 { + t.Log(msg) + } } } } diff --git a/backend/models/models.go b/backend/models/models.go index 434aa91..cc56ed5 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -195,6 +195,12 @@ func (receiver StockInfoUS) TableName() string { type Resp struct { Code int `json:"code"` Message string `json:"message"` + Error struct { + Code string `json:"code"` + Message string `json:"message"` + Param string `json:"param"` + Type string `json:"type"` + } `json:"error"` } type PromptTemplate struct {