fix: 修复在线知识库爬取文档名超过128个字符报错 #706 (#778)

This commit is contained in:
shaohuzhang1 2024-07-16 10:59:13 +08:00 committed by wangdan-fit2cloud
parent 5dfe56cefb
commit 6a337f7ecd

View File

@ -666,13 +666,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,