Compare commits

...

5 Commits

Author SHA1 Message Date
ArvinLovegood
ca4727db80 fix(app):更新股票研究报告工具描述
- 修改了GetStockResearchReport函数的描述信息
- 简化了描述文本,去除冗余的"机构的"前缀
- 保持了原有功能和参数结构不变
2025-09-27 19:12:51 +08:00
ArvinLovegood
84ffe7c5fd refactor(openai_api):移除行业板块相关工具调用逻辑
- 注释掉QueryBKDictInfo工具的调用实现
- 注释掉GetIndustryResearchReport工具的调用实现
- 移除对freecache包的依赖引用- 保留GetStockResearchReport工具的调用逻辑
- 简化工具调用处理流程
2025-09-27 18:55:28 +08:00
ArvinLovegood
da02d1bd1c feat(stock):更新股票研究报接口参数并完善行业研究描述
- 修改行业研究工具函数描述,增加调用前需查询行业代码的提示
- 更新股票研究报接口测试用例中的股票代码参数值
- 完善行业研究报相关功能的使用说明和参数校验逻辑- 优化研究报数据获取流程,提升接口稳定性与准确性
2025-09-27 16:59:05 +08:00
ArvinLovegood
bae2bf9c5c docs(readme): 更新AI智能选股功能描述
- 在功能说明中添加AI智能体功能的描述
- 保持其他功能状态和备注信息不变
2025-09-27 15:46:33 +08:00
ArvinLovegood
6568b5949a docs(readme): 更新AI智能选股功能状态
- 将AI智能选股功能状态从开发中更新为已完成
- 修改功能描述为"市场行情-》AI总结"
- 调整了功能备注信息的表述方式
2025-09-27 15:44:03 +08:00
4 changed files with 118 additions and 119 deletions

View File

@@ -62,7 +62,7 @@
| 功能说明 | 状态 | 备注 |
|-----------------|----|----------------------------------------------------------------------------------------------------------|
| 股票分析知识库 | 🚧 | 未来计划 |
| Ai智能选股 | 🚧 | Ai智能选股功能开发中(下半年重点开发计划) |
| Ai智能选股 | | Ai智能选股功能(市场行情-》AI总结/AI智能体功能) |
| ETF支持 | 🚧 | ETF数据支持 (目前可以查看净值和估值) |
| 美股支持 | ✅ | 美股数据支持 |
| 港股支持 | ✅ | 港股数据支持 |

50
app.go
View File

@@ -131,37 +131,37 @@ func AddTools(tools []data.Tool) []data.Tool {
},
})
tools = append(tools, data.Tool{
Type: "function",
Function: data.ToolFunction{
Name: "QueryBKDictInfo",
Description: "获取所有板块/行业名称或者代码(bkCode,bkName)",
},
})
//tools = append(tools, data.Tool{
// Type: "function",
// Function: data.ToolFunction{
// Name: "QueryBKDictInfo",
// Description: "获取所有板块/行业名称或者代码(bkCode,bkName)",
// },
//})
tools = append(tools, data.Tool{
Type: "function",
Function: data.ToolFunction{
Name: "GetIndustryResearchReport",
Description: "获取行业/板块研究报告",
Parameters: data.FunctionParameters{
Type: "object",
Properties: map[string]any{
"bkCode": map[string]any{
"type": "string",
"description": "板块/行业代码",
},
},
Required: []string{"bkCode"},
},
},
})
//tools = append(tools, data.Tool{
// Type: "function",
// Function: data.ToolFunction{
// Name: "GetIndustryResearchReport",
// Description: "获取行业/板块研究报告,请先使用QueryBKDictInfo工具获取行业代码然后输入行业代码调用",
// Parameters: data.FunctionParameters{
// Type: "object",
// Properties: map[string]any{
// "bkCode": map[string]any{
// "type": "string",
// "description": "板块/行业代码",
// },
// },
// Required: []string{"bkCode"},
// },
// },
//})
tools = append(tools, data.Tool{
Type: "function",
Function: data.ToolFunction{
Name: "GetStockResearchReport",
Description: "获取机构的股票分析/研究报告",
Description: "获取股票分析/研究报告",
Parameters: data.FunctionParameters{
Type: "object",
Properties: map[string]any{

View File

@@ -73,7 +73,7 @@ func TestLongTiger(t *testing.T) {
func TestStockResearchReport(t *testing.T) {
db.Init("../../data/stock.db")
resp := NewMarketNewsApi().StockResearchReport("600584.sh", 7)
resp := NewMarketNewsApi().StockResearchReport("688082", 7)
for _, a := range resp {
logger.SugaredLogger.Debugf("value: %+v", a)
data := a.(map[string]any)

View File

@@ -16,7 +16,6 @@ import (
"github.com/PuerkitoBio/goquery"
"github.com/chromedp/chromedp"
"github.com/coocood/freecache"
"github.com/duke-git/lancet/v2/convertor"
"github.com/duke-git/lancet/v2/random"
"github.com/duke-git/lancet/v2/strutil"
@@ -1367,98 +1366,98 @@ func AskAiWithTools(o *OpenAi, err error, messages []map[string]interface{}, ch
"tool_call_id": currentCallId,
})
}
//
//if funcName == "QueryBKDictInfo" {
// ch <- map[string]any{
// "code": 1,
// "question": question,
// "chatId": streamResponse.Id,
// "model": streamResponse.Model,
// "content": "\r\n```\r\n开始调用工具QueryBKDictInfo\n参数" + funcArguments + "\r\n```\r\n",
// "time": time.Now().Format(time.DateTime),
// }
// res := NewMarketNewsApi().EMDictCode("016", freecache.NewCache(100))
// bytes, err := json.Marshal(res)
// if err != nil {
// return
// }
// dict := &[]models.BKDict{}
// json.Unmarshal(bytes, dict)
// md := util.MarkdownTableWithTitle("行业/板块代码", dict)
// logger.SugaredLogger.Infof("行业/板块代码=\n%s", md)
// messages = append(messages, map[string]interface{}{
// "role": "assistant",
// "content": currentAIContent.String(),
// "tool_calls": []map[string]any{
// {
// "id": currentCallId,
// "tool_call_id": currentCallId,
// "type": "function",
// "function": map[string]string{
// "name": funcName,
// "arguments": funcArguments,
// "parameters": funcArguments,
// },
// },
// },
// })
// messages = append(messages, map[string]interface{}{
// "role": "tool",
// "content": md,
// "tool_call_id": currentCallId,
// })
//}
if funcName == "QueryBKDictInfo" {
ch <- map[string]any{
"code": 1,
"question": question,
"chatId": streamResponse.Id,
"model": streamResponse.Model,
"content": "\r\n```\r\n开始调用工具QueryBKDictInfo\n参数" + funcArguments + "\r\n```\r\n",
"time": time.Now().Format(time.DateTime),
}
res := NewMarketNewsApi().EMDictCode("016", freecache.NewCache(100))
bytes, err := json.Marshal(res)
if err != nil {
return
}
dict := &[]models.BKDict{}
json.Unmarshal(bytes, dict)
md := util.MarkdownTableWithTitle("行业/板块代码", dict)
logger.SugaredLogger.Infof("行业/板块代码=\n%s", md)
messages = append(messages, map[string]interface{}{
"role": "assistant",
"content": currentAIContent.String(),
"tool_calls": []map[string]any{
{
"id": currentCallId,
"tool_call_id": currentCallId,
"type": "function",
"function": map[string]string{
"name": funcName,
"arguments": funcArguments,
"parameters": funcArguments,
},
},
},
})
messages = append(messages, map[string]interface{}{
"role": "tool",
"content": md,
"tool_call_id": currentCallId,
})
}
if funcName == "GetIndustryResearchReport" {
bkCode := gjson.Get(funcArguments, "bkCode").String()
ch <- map[string]any{
"code": 1,
"question": question,
"chatId": streamResponse.Id,
"model": streamResponse.Model,
"content": "\r\n```\r\n开始调用工具GetIndustryResearchReport\n参数" + bkCode + "\r\n```\r\n",
"time": time.Now().Format(time.DateTime),
}
bkCode = strutil.ReplaceWithMap(bkCode, map[string]string{
"-": "",
"_": "",
"bk": "",
"BK": "",
"bk0": "",
"BK0": "",
})
logger.SugaredLogger.Debugf("code:%s", bkCode)
codeStr := convertor.ToString(bkCode)
res := NewMarketNewsApi().IndustryResearchReport(codeStr, 7)
md := strings.Builder{}
for _, a := range res {
d := a.(map[string]any)
md.WriteString(NewMarketNewsApi().GetIndustryReportInfo(d["infoCode"].(string)))
}
logger.SugaredLogger.Infof("bkCode:%s IndustryResearchReport:\n %s", bkCode, md.String())
messages = append(messages, map[string]interface{}{
"role": "assistant",
"content": currentAIContent.String(),
"tool_calls": []map[string]any{
{
"id": currentCallId,
"tool_call_id": currentCallId,
"type": "function",
"function": map[string]string{
"name": funcName,
"arguments": funcArguments,
"parameters": funcArguments,
},
},
},
})
messages = append(messages, map[string]interface{}{
"role": "tool",
"content": md.String(),
"tool_call_id": currentCallId,
})
}
//if funcName == "GetIndustryResearchReport" {
// bkCode := gjson.Get(funcArguments, "bkCode").String()
// ch <- map[string]any{
// "code": 1,
// "question": question,
// "chatId": streamResponse.Id,
// "model": streamResponse.Model,
// "content": "\r\n```\r\n开始调用工具GetIndustryResearchReport\n参数" + bkCode + "\r\n```\r\n",
// "time": time.Now().Format(time.DateTime),
// }
// bkCode = strutil.ReplaceWithMap(bkCode, map[string]string{
// "-": "",
// "_": "",
// "bk": "",
// "BK": "",
// "bk0": "",
// "BK0": "",
// })
//
// logger.SugaredLogger.Debugf("code:%s", bkCode)
// codeStr := convertor.ToString(bkCode)
// res := NewMarketNewsApi().IndustryResearchReport(codeStr, 7)
// md := strings.Builder{}
// for _, a := range res {
// d := a.(map[string]any)
// md.WriteString(NewMarketNewsApi().GetIndustryReportInfo(d["infoCode"].(string)))
// }
// logger.SugaredLogger.Infof("bkCode:%s IndustryResearchReport:\n %s", bkCode, md.String())
// messages = append(messages, map[string]interface{}{
// "role": "assistant",
// "content": currentAIContent.String(),
// "tool_calls": []map[string]any{
// {
// "id": currentCallId,
// "tool_call_id": currentCallId,
// "type": "function",
// "function": map[string]string{
// "name": funcName,
// "arguments": funcArguments,
// "parameters": funcArguments,
// },
// },
// },
// })
// messages = append(messages, map[string]interface{}{
// "role": "tool",
// "content": md.String(),
// "tool_call_id": currentCallId,
// })
//}
if funcName == "GetStockResearchReport" {
stockCode := gjson.Get(funcArguments, "stockCode").String()