|
@@ -38,8 +38,6 @@ func (l *UploadAgentDataLogic) UploadAgentData(req *types.UploadDataReq, file mu
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- fmt.Printf("req=%+v", *req)
|
|
|
-
|
|
|
agent, err := l.svcCtx.DB.Agent.Query().Where(agentModel.ID(agentId)).Only(l.ctx)
|
|
|
if err != nil {
|
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
@@ -54,14 +52,24 @@ func (l *UploadAgentDataLogic) UploadAgentData(req *types.UploadDataReq, file mu
|
|
|
|
|
|
qas := make([]fastgpt.DataQuestion, 0, 100)
|
|
|
for idx, record := range records {
|
|
|
- //l.Logger.Infof("idx=>%d 0=>%s 1=>%s\n", idx, record[0], record[1])
|
|
|
+ // 第一行标题内容过滤
|
|
|
+ //fmt.Printf("idx=%v, q=%v, a=%v \n", idx, record[0], record[1])
|
|
|
+ //fmt.Println(idx == 0, record[0] == "问题", record[1] == "答案")
|
|
|
+ //fmt.Printf("record=%+v\n", record)
|
|
|
+ if idx == 0 && record[1] == "答案" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 空内容过滤
|
|
|
+ if record[0] == "" || record[1] == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
qas = append(qas, fastgpt.DataQuestion{
|
|
|
Q: record[0],
|
|
|
A: record[1],
|
|
|
})
|
|
|
if idx%100 == 0 && len(qas) > 0 {
|
|
|
params.Data = qas
|
|
|
- //response, err := fastgpt.DiyCreateBulkData(token, ¶ms)
|
|
|
response, err := fastgpt.CreateBulkData(¶ms)
|
|
|
if err != nil {
|
|
|
l.Logger.Errorf("batch insert data to fastgpt failed. collection=%s error=%s", agent.CollectionID, err.Error())
|
|
@@ -75,7 +83,6 @@ func (l *UploadAgentDataLogic) UploadAgentData(req *types.UploadDataReq, file mu
|
|
|
if len(qas) > 0 {
|
|
|
params.Data = qas
|
|
|
response, err := fastgpt.DiyCreateBulkData(token, ¶ms)
|
|
|
- //response, err := fastgpt.CreateBulkData(¶ms)
|
|
|
if err != nil {
|
|
|
l.Logger.Errorf("batch insert data to fastgpt failed. collection=%s error=%s", agent.CollectionID, err.Error())
|
|
|
return nil, err
|