You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.0 KiB
82 lines
3.0 KiB
package echomeet
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// @Summary 会议记录智能总结
|
|
// @Description 按指定模板和语言对已有会议记录重新 AI 总结(转写内容不翻译,语言只作用于总结)
|
|
// @Tags Echomeet
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param user body pb.EchomeetSummaryReq true "请求数据"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.EchomeetAddRecordResp} "响应数据"
|
|
// @Router /api/home/echomeet_summary [post]
|
|
func (this *apiComp) Summary(session comm.IUserSession, req *pb.EchomeetSummaryReq) (resp *pb.EchomeetAddRecordResp, errdata *pb.ErrorData) {
|
|
var (
|
|
model *pb.DBEchoMeetRecord
|
|
err error
|
|
)
|
|
uid, errdata := requireUID(session)
|
|
if errdata != nil {
|
|
return
|
|
}
|
|
if model, err = this.module.model.getrecordforuid(uid, req.Id); err != nil {
|
|
errdata = recordErr(err)
|
|
return
|
|
}
|
|
// 确定总结语言:空串 = 沿用记录上次的(老客户端的语义,保留);
|
|
// "auto" = 改回不翻译(跟随录音语言);其余 = 用这个语言写总结。
|
|
language := model.Tolanguage
|
|
if req.Tolanguage != "" {
|
|
language = normalizeAutoLang(req.Tolanguage)
|
|
}
|
|
// 确定模板:tid 优先,其次 req.Templateid,最后沿用记录中的 templateid
|
|
tid := req.Tid
|
|
templateid := req.Templateid
|
|
if tid == "" && templateid == 0 {
|
|
templateid = model.Templateid
|
|
}
|
|
// templateid 是某一语种的主键,按主键查到的还是原语种模板。
|
|
// 仅公共模板(id<起点)有多语言版本,切换语言时通过 tid 反查对应版本;
|
|
// 私有模板(id>=起点)单条、无多语言版本,保持按主键解析,不反查 tid。
|
|
if tid == "" && templateid != 0 && templateid < templatePrivateIdStart {
|
|
if base, berr := this.module.cache.GetTemplateForId(templateid); berr == nil && base.Tid != "" {
|
|
tid = base.Tid
|
|
}
|
|
}
|
|
tmpl, err := this.module.cache.ResolveSummaryTemplate(tid, templateid, language)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_TemplateNotFound,
|
|
Message: "模板不存在或不支持该语言",
|
|
}
|
|
return
|
|
}
|
|
model.Templateid = tmpl.Id
|
|
// 总结模型:请求显式指定(须后台开关允许且在可选列表内)优先,否则沿用记录已有,再否则后台默认。
|
|
if req.SummarySvcId != "" || model.LlmSvcId == "" {
|
|
llmSvcId, _, perr := this.module.providers.PickLLM(req.SummarySvcId)
|
|
if perr != nil {
|
|
errdata = &pb.ErrorData{Code: pb.ErrorCode_SystemError, Message: perr.Error()}
|
|
return
|
|
}
|
|
model.LlmSvcId = llmSvcId
|
|
}
|
|
this.module.Infof("Summary id:%d → llm:%s", model.Id, model.LlmSvcId)
|
|
// 转写内容不再翻译(2026-09-26),换总结语言只需改 Tolanguage 再总结一次,
|
|
// 由 AIProcess 按它给大模型下输出语言指令。
|
|
model.Tolanguage = language
|
|
if model.Translate == "" {
|
|
model.Translate = model.Original
|
|
}
|
|
this.module.Infof("Summary id:%d → 总结语言:%q", model.Id, language)
|
|
this.module.model.saverecord(model)
|
|
_ = this.module.tasks.SubmitAITask(model)
|
|
resp = &pb.EchomeetAddRecordResp{
|
|
Record: model,
|
|
}
|
|
return
|
|
}
|
|
|