fix: 修改服务调用和测试用例

This commit is contained in:
renzhiyuan 2026-03-11 10:50:33 +08:00
parent ec53207225
commit 041e9fad0b
4 changed files with 34 additions and 22 deletions

View File

@ -93,7 +93,9 @@ func (h *Hsyq) CreateResponse(ctx context.Context, key string, modelName string,
}, },
}, },
Stream: new(bool), Stream: new(bool),
Reasoning: &responses.ResponsesReasoning{Effort: responses.ReasoningEffort_minimal},
Thinking: &responses.ResponsesThinking{Type: responses.ThinkingType_disabled.Enum()}, Thinking: &responses.ResponsesThinking{Type: responses.ThinkingType_disabled.Enum()},
Text: &responses.ResponsesText{Format: &responses.TextFormat{Type: responses.TextType_json_object}},
} }
if isRegis { if isRegis {
prefix := true prefix := true
@ -126,6 +128,7 @@ func (h *Hsyq) RequestHsyqJson(ctx context.Context, key string, modelName string
}, },
}, },
Stream: new(bool), Stream: new(bool),
Thinking: &responses.ResponsesThinking{Type: responses.ThinkingType_disabled.Enum()}, Thinking: &responses.ResponsesThinking{Type: responses.ThinkingType_disabled.Enum()},
Text: &responses.ResponsesText{Format: &responses.TextFormat{Type: responses.TextType_json_object}}, Text: &responses.ResponsesText{Format: &responses.TextFormat{Type: responses.TextType_json_object}},
} }

View File

@ -21,7 +21,7 @@ import (
func Test_WordAna(t *testing.T) { func Test_WordAna(t *testing.T) {
Run(context.Background(), nil) Run(context.Background(), nil)
ana, err := file.WordAnat("https://attachment-public.oss-cn-hangzhou.aliyuncs.com/ai-scheduler/data-analytics/word/content2.docx") ana, err := fileService.WordAnat("https://attachment-public.oss-cn-hangzhou.aliyuncs.com/ai-scheduler/data-analytics/word/content2.docx")
t.Log(ana, err) t.Log(ana, err)
} }
@ -29,35 +29,35 @@ func Test_AdvicerInit(t *testing.T) {
reqBody := `{"advicer_id": 124, "name": "张三111", "birth": "1990-01-01", "gender": 1, "working_years": 10}` reqBody := `{"advicer_id": 124, "name": "张三111", "birth": "1990-01-01", "gender": 1, "working_years": 10}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := advicer.AdvicerUpdate(fiberCtx) err := advicerService.AdvicerUpdate(fiberCtx)
t.Log(err) t.Log(err)
} }
func Test_AdvicerVersionAdd(t *testing.T) { func Test_AdvicerVersionAdd(t *testing.T) {
reqBody := `{"advicerId":124,"versionDesc":"第三个版本","dialectFeatures":{"region":"四川成都话","intensity":0.6,"KeyWords":null},"personalityTags":["耐心细致","专业务实","经验丰富","善于引导"],"sentencePatterns":{"openingMode":["我给你介绍一下","我们先来看一下","这边请"],"explanationMode":["是这样的","我跟你讲","你发现没得","说白了"],"confirmationMode":["对吧?","是不是嘛?","你晓得不?","明白了噻?","对不对?"],"summaryMode":["所以说","简单说就是","其实"],"transitionMode":["然后的话","再其次","还有一点","另外"]},"signatureDialogues":[{"context":"客户质疑地块大小","dialogue":"哥14亩确实不大但你要在成都2.5环内城买房这种是普遍现象。你看万景和绿城都是13亩中铁建只有8.8亩339那个帮泰只有11亩。我们虽然地小但楼间距开阔啊看过去都是200多米而且小小区人少安静圈层更纯粹"},{"context":"客户担心物业费高","dialogue":"姐我懂你意思我们也觉得物业费是有点贵。但招商物业是铂金服务有夜间送外卖、免费宠物喂养、年度保洁这些增值服务。而且前三年开发商补贴一块钱只需要交5块跟其他盘差不多好物业能让房子后期保值增值更多"},{"context":"客户犹豫价格","dialogue":"说实话这个地段的地价都比二八板块贵5000多但我们单价只贵3000。你看龙湖滨江云河颂套内单价都36000了我们才33000真的性价比高现在不买以后这个板块可能就买不起了。"},{"context":"客户担心小区小不保值","dialogue":"哥你不用担心小地块不保值东大街的九龙仓擎天半岛只有两栋楼现在二手房还能卖3万左右是当年的豪宅项目。还有望江名门、仁和春天29号院都是小地块但照样是高端保值盘。核心还是地段我们在槐树店这个成华区最贵的板块保值根本没问题"}],"toneTags":{"enthusiasm":0.8,"patience":0.9,"confidence":0.85,"friendliness":0.8,"persuasion":0.75}}` reqBody := `{"advicerId":124,"versionDesc":"第三个版本","dialectFeatures":{"region":"四川成都话","intensity":0.6,"KeyWords":null},"personalityTags":["耐心细致","专业务实","经验丰富","善于引导"],"sentencePatterns":{"openingMode":["我给你介绍一下","我们先来看一下","这边请"],"explanationMode":["是这样的","我跟你讲","你发现没得","说白了"],"confirmationMode":["对吧?","是不是嘛?","你晓得不?","明白了噻?","对不对?"],"summaryMode":["所以说","简单说就是","其实"],"transitionMode":["然后的话","再其次","还有一点","另外"]},"signatureDialogues":[{"context":"客户质疑地块大小","dialogue":"哥14亩确实不大但你要在成都2.5环内城买房这种是普遍现象。你看万景和绿城都是13亩中铁建只有8.8亩339那个帮泰只有11亩。我们虽然地小但楼间距开阔啊看过去都是200多米而且小小区人少安静圈层更纯粹"},{"context":"客户担心物业费高","dialogue":"姐我懂你意思我们也觉得物业费是有点贵。但招商物业是铂金服务有夜间送外卖、免费宠物喂养、年度保洁这些增值服务。而且前三年开发商补贴一块钱只需要交5块跟其他盘差不多好物业能让房子后期保值增值更多"},{"context":"客户犹豫价格","dialogue":"说实话这个地段的地价都比二八板块贵5000多但我们单价只贵3000。你看龙湖滨江云河颂套内单价都36000了我们才33000真的性价比高现在不买以后这个板块可能就买不起了。"},{"context":"客户担心小区小不保值","dialogue":"哥你不用担心小地块不保值东大街的九龙仓擎天半岛只有两栋楼现在二手房还能卖3万左右是当年的豪宅项目。还有望江名门、仁和春天29号院都是小地块但照样是高端保值盘。核心还是地段我们在槐树店这个成华区最贵的板块保值根本没问题"}],"toneTags":{"enthusiasm":0.8,"patience":0.9,"confidence":0.85,"friendliness":0.8,"persuasion":0.75}}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := advicer.AdvicerVersionAdd(fiberCtx) err := advicerService.AdvicerVersionAdd(fiberCtx)
t.Log(err) t.Log(err)
} }
func Test_AdvicerVersionUpdate(t *testing.T) { func Test_AdvicerVersionUpdate(t *testing.T) {
reqBody := `{"id":"69804b5a6532131383aeda3a","advicerId":124,"versionDesc":"第三个版本","dialectFeatures":{"region":"四川成都话","intensity":0.6,"KeyWords":null},"personalityTags":["耐心细致","专业务实","经验丰富","善于引导"],"sentencePatterns":{"openingMode":["我给你介绍一下","我们先来看一下","这边请"],"explanationMode":["是这样的","我跟你讲","你发现没得","说白了"],"confirmationMode":["对吧?","是不是嘛?","你晓得不?","明白了噻?","对不对?"],"summaryMode":["所以说","简单说就是","其实"],"transitionMode":["然后的话","再其次","还有一点","另外"]},"signatureDialogues":[{"context":"客户质疑地块大小","dialogue":"哥14亩确实不大但你要在成都2.5环内城买房这种是普遍现象。你看万景和绿城都是13亩中铁建只有8.8亩339那个帮泰只有11亩。我们虽然地小但楼间距开阔啊看过去都是200多米而且小小区人少安静圈层更纯粹"},{"context":"客户担心物业费高","dialogue":"姐我懂你意思我们也觉得物业费是有点贵。但招商物业是铂金服务有夜间送外卖、免费宠物喂养、年度保洁这些增值服务。而且前三年开发商补贴一块钱只需要交5块跟其他盘差不多好物业能让房子后期保值增值更多"},{"context":"客户犹豫价格","dialogue":"说实话这个地段的地价都比二八板块贵5000多但我们单价只贵3000。你看龙湖滨江云河颂套内单价都36000了我们才33000真的性价比高现在不买以后这个板块可能就买不起了。"},{"context":"客户担心小区小不保值","dialogue":"哥你不用担心小地块不保值东大街的九龙仓擎天半岛只有两栋楼现在二手房还能卖3万左右是当年的豪宅项目。还有望江名门、仁和春天29号院都是小地块但照样是高端保值盘。核心还是地段我们在槐树店这个成华区最贵的板块保值根本没问题"}],"toneTags":{"enthusiasm":0.8,"patience":0.9,"confidence":0.85,"friendliness":0.8,"persuasion":0.75}}` reqBody := `{"id":"69804b5a6532131383aeda3a","advicerId":124,"versionDesc":"第三个版本","dialectFeatures":{"region":"四川成都话","intensity":0.6,"KeyWords":null},"personalityTags":["耐心细致","专业务实","经验丰富","善于引导"],"sentencePatterns":{"openingMode":["我给你介绍一下","我们先来看一下","这边请"],"explanationMode":["是这样的","我跟你讲","你发现没得","说白了"],"confirmationMode":["对吧?","是不是嘛?","你晓得不?","明白了噻?","对不对?"],"summaryMode":["所以说","简单说就是","其实"],"transitionMode":["然后的话","再其次","还有一点","另外"]},"signatureDialogues":[{"context":"客户质疑地块大小","dialogue":"哥14亩确实不大但你要在成都2.5环内城买房这种是普遍现象。你看万景和绿城都是13亩中铁建只有8.8亩339那个帮泰只有11亩。我们虽然地小但楼间距开阔啊看过去都是200多米而且小小区人少安静圈层更纯粹"},{"context":"客户担心物业费高","dialogue":"姐我懂你意思我们也觉得物业费是有点贵。但招商物业是铂金服务有夜间送外卖、免费宠物喂养、年度保洁这些增值服务。而且前三年开发商补贴一块钱只需要交5块跟其他盘差不多好物业能让房子后期保值增值更多"},{"context":"客户犹豫价格","dialogue":"说实话这个地段的地价都比二八板块贵5000多但我们单价只贵3000。你看龙湖滨江云河颂套内单价都36000了我们才33000真的性价比高现在不买以后这个板块可能就买不起了。"},{"context":"客户担心小区小不保值","dialogue":"哥你不用担心小地块不保值东大街的九龙仓擎天半岛只有两栋楼现在二手房还能卖3万左右是当年的豪宅项目。还有望江名门、仁和春天29号院都是小地块但照样是高端保值盘。核心还是地段我们在槐树店这个成华区最贵的板块保值根本没问题"}],"toneTags":{"enthusiasm":0.8,"patience":0.9,"confidence":0.85,"friendliness":0.8,"persuasion":0.75}}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := advicer.AdvicerVersionUpdate(fiberCtx) err := advicerService.AdvicerVersionUpdate(fiberCtx)
t.Log(err) t.Log(err)
} }
func Test_VersionList(t *testing.T) { func Test_VersionList(t *testing.T) {
reqBody := `{"id":"69804060c17976e5e21858a8"}` reqBody := `{"id":"69804060c17976e5e21858a8"}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := advicer.AdvicerVersionList(fiberCtx) err := advicerService.AdvicerVersionList(fiberCtx)
t.Log(err) t.Log(err)
} }
func Test_AdvicerVersionDel(t *testing.T) { func Test_AdvicerVersionDel(t *testing.T) {
reqBody := `{"id":"698056073059550befc4f0da"}` reqBody := `{"id":"698056073059550befc4f0da"}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := advicer.AdvicerVersionDel(fiberCtx) err := advicerService.AdvicerVersionDel(fiberCtx)
t.Log(err) t.Log(err)
} }
@ -93,8 +93,9 @@ func Test_Json(t *testing.T) {
} }
var ( var (
file *FileService fileService *FileService
advicer *AdvicerService advicerService *AdvicerService
adviceChatService *ChatService
configConfig *config.Config configConfig *config.Config
fiberCtx *fiber.Ctx fiberCtx *fiber.Ctx
) )
@ -115,23 +116,31 @@ func Run(ctx context.Context, reqBody []byte) {
rdb := utils.NewRdb(configConfig) rdb := utils.NewRdb(configConfig)
advicerImpl := impl.NewAdviceAdvicerImpl(db) advicerImpl := impl.NewAdviceAdvicerImpl(db)
advicerVersionMongo := mongo_model.NewAdvicerVersionMongo() advicerVersionMongo := mongo_model.NewAdvicerVersionMongo()
advicerChatHisMongo := mongo_model.NewAdvicerChatHisMongo()
aiAdviceModelSupImpl := impl.NewAiAdviceModelSupImpl(db)
aiAdviceSessionImpl := impl.NewAiAdviceSessionImpl(db)
advicerTalkSkillMongo := mongo_model.NewAdvicerTalkSkillMongo() advicerTalkSkillMongo := mongo_model.NewAdvicerTalkSkillMongo()
advicerClientMongo := mongo_model.NewAdvicerClientMongo() advicerClientMongo := mongo_model.NewAdvicerClientMongo()
advicerProjectMongo := mongo_model.NewAdvicerProjectMongo() advicerProjectMongo := mongo_model.NewAdvicerProjectMongo()
hsyq := third_party.NewHsyq() hsyq := third_party.NewHsyq()
advicerfilebiz := biz.NewAdviceFileBiz(hsyq)
adviceProjectImpl := impl.NewAdviceProjectImpl(db)
mongo, _ := pkg.NewMongoDb(ctx, configConfig) mongo, _ := pkg.NewMongoDb(ctx, configConfig)
adviceAdvicerBiz := biz.NewAdviceAdvicerBiz(advicerImpl, advicerVersionMongo, mongo) adviceAdvicerBiz := biz.NewAdviceAdvicerBiz(advicerImpl, advicerVersionMongo, mongo)
adviceChatBiz := biz.NewAdviceChatBiz(hsyq, rdb, aiAdviceSessionImpl, aiAdviceModelSupImpl, advicerChatHisMongo, mongo)
skillBiz := biz.NewAdviceSkillBiz(advicerTalkSkillMongo, mongo) skillBiz := biz.NewAdviceSkillBiz(advicerTalkSkillMongo, mongo)
clientBiz := biz.NewAdviceClientBiz(advicerClientMongo, mongo) clientBiz := biz.NewAdviceClientBiz(advicerClientMongo, mongo)
projectBiz := biz.NewAdviceProjectBiz(advicerProjectMongo, mongo) adviceFileBiz := biz.NewAdviceFileBiz(hsyq)
chatBiz := biz.NewAdviceChatBiz(hsyq, rdb) adviceProjectBiz := biz.NewAdviceProjectBiz(advicerProjectMongo, adviceProjectImpl, aiAdviceModelSupImpl, mongo)
file = NewFileService(advicerfilebiz, configConfig) adviceClientBiz := biz.NewAdviceClientBiz(advicerClientMongo, mongo)
advicer = NewAdvicerService(adviceAdvicerBiz, configConfig) adviceSkillBiz := biz.NewAdviceSkillBiz(advicerTalkSkillMongo, mongo)
fileService = NewFileService(adviceFileBiz, configConfig, adviceProjectBiz)
advicerService = NewAdvicerService(adviceAdvicerBiz, configConfig)
skill = NewTalkSkillService(skillBiz, configConfig) skill = NewTalkSkillService(skillBiz, configConfig)
client = NewClientService(clientBiz, configConfig) client = NewClientService(clientBiz, configConfig)
project = NewProjectService(projectBiz, configConfig) project = NewProjectService(adviceProjectBiz, configConfig)
chat = NewChatService(chatBiz, clientBiz, adviceAdvicerBiz, projectBiz, skillBiz, configConfig) adviceChatService = NewChatService(adviceChatBiz, adviceClientBiz, adviceAdvicerBiz, adviceProjectBiz, adviceSkillBiz, configConfig)
} }
var dataMap = map[string]mongo_model.AdviceData{ var dataMap = map[string]mongo_model.AdviceData{

View File

@ -9,7 +9,7 @@ import (
) )
func Test_Regis(t *testing.T) { func Test_Regis(t *testing.T) {
reqBody := `{"advicerVersionId":"698315725d0077330399f704","clientId":"698199fa0c5f4ae098e009ab","talkSkillId":"698063ff5215bdb9c6344e88"}` reqBody := `{"advicerVersionId":"698315725d0077330399f704","clientId":"69819b3403152e79c5ac8ca9","talkSkillId":"6980651219c4ac11078c341e"}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := chat.Regis(fiberCtx) err := chat.Regis(fiberCtx)
t.Log(err) t.Log(err)

View File

@ -30,7 +30,7 @@ func Test_ClientList(t *testing.T) {
func Test_ClientDel(t *testing.T) { func Test_ClientDel(t *testing.T) {
reqBody := `{"id":"698056073059550befc4f0da"}` reqBody := `{"id":"698056073059550befc4f0da"}`
Run(context.Background(), []byte(reqBody)) Run(context.Background(), []byte(reqBody))
err := advicer.AdvicerVersionDel(fiberCtx) err := advicerService.AdvicerVersionDel(fiberCtx)
t.Log(err) t.Log(err)
} }