fix: 修复在线知识库爬取文档名超过128个字符报错 #706 (#778)
Some checks failed
sync2gitee / repo-sync (push) Has been cancelled
Typos Check / Spell Check with Typos (push) Has been cancelled

(cherry picked from commit 3249811428)
This commit is contained in:
shaohuzhang1 2024-07-16 10:59:13 +08:00 committed by shaohuzhang1
parent 56a7b7b524
commit 499fc90f2f

View File

@ -656,13 +656,13 @@ class DocumentSerializers(ApiMixin, serializers.Serializer):
paragraphs = get_split_model('web.md').parse(response.content)
# 插入
DocumentSerializers.Create(data={'dataset_id': dataset_id}).save(
{'name': source_url, 'paragraphs': paragraphs,
{'name': source_url[0:128], 'paragraphs': paragraphs,
'meta': {'source_url': source_url, 'selector': selector},
'type': Type.web}, with_valid=True)
except Exception as e:
logging.getLogger("max_kb_error").error(f'{str(e)}:{traceback.format_exc()}')
else:
Document(name=source_url,
Document(name=source_url[0:128],
meta={'source_url': source_url, 'selector': selector},
type=Type.web,
char_length=0,