import { CodeGroup } from '@/app/components/develop/code.tsx' import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstruction, Paragraph } from '@/app/components/develop/md.tsx' # 知识库 API
book
图书 Book
- web_page
网页 Web page
- paper
学术论文/文章 Academic paper/article
- social_media_post
社交媒体帖子 Social media post
- wikipedia_entry
维基百科条目 Wikipedia entry
- personal_document
个人文档 Personal document
- business_document
商业文档 Business document
- im_chat_log
即时通讯记录 Chat log
- synced_from_notion
Notion同步文档 Notion document
- synced_from_github
GitHub同步文档 GitHub document
- others
其他文档类型 Other document types
book
:
- title
书名 Book title
- language
图书语言 Book language
- author
作者 Book author
- publisher
出版社 Publisher name
- publication_date
出版日期 Publication date
- isbn
ISBN号码 ISBN number
- category
图书分类 Book category
针对网页 For web_page
:
- title
页面标题 Page title
- url
页面网址 Page URL
- language
页面语言 Page language
- publish_date
发布日期 Publish date
- author/publisher
作者/发布者 Author or publisher
- topic/keywords
主题/关键词 Topic or keywords
- description
页面描述 Page description
请查看 [api/services/dataset_service.py](https://github.com/langgenius/dify/blob/main/api/services/dataset_service.py#L475) 了解各文档类型所需字段的详细信息。
针对"其他"类型文档,接受任何有效的JSON对象
high_quality
高质量:使用 embedding 模型进行嵌入,构建为向量数据库索引
- economy
经济:使用 keyword table index 的倒排索引进行构建
text_model
text 文档直接 embedding,经济模式默认为该模式
- hierarchical_model
parent-child 模式
- qa_model
Q&A 模式:为分片文档生成 Q&A 对,然后对问题进行 embedding
English
、Chinese
mode
(string) 清洗、分段模式 ,automatic 自动 / custom 自定义
- rules
(object) 自定义规则(自动模式下,该字段为空)
- pre_processing_rules
(array[object]) 预处理规则
- id
(string) 预处理规则的唯一标识符
- 枚举:
- remove_extra_spaces
替换连续空格、换行符、制表符
- remove_urls_emails
删除 URL、电子邮件地址
- enabled
(bool) 是否选中该规则,不传入文档 ID 时代表默认值
- segmentation
(object) 分段规则
- separator
自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
- max_tokens
最大长度(token)默认为 1000
- parent_mode
父分段的召回模式 full-doc
全文召回 / paragraph
段落召回
- subchunk_segmentation
(object) 子分段规则
- separator
分段标识符,目前仅允许设置一个分隔符。默认为 ***
- max_tokens
最大长度 (token) 需要校验小于父级的长度
- chunk_overlap
分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
search_method
(string) 检索方法
- hybrid_search
混合检索
- semantic_search
语义检索
- full_text_search
全文检索
- reranking_enable
(bool) 是否开启rerank
- reranking_model
(object) Rerank 模型配置
- reranking_provider_name
(string) Rerank 模型的提供商
- reranking_model_name
(string) Rerank 模型的名称
- top_k
(int) 召回条数
- score_threshold_enabled
(bool)是否开启召回分数限制
- score_threshold
(float) 召回分数限制
original_document_id
源文档 ID(选填)
- 用于重新上传文档或修改文档清洗、分段配置,缺失的信息从源文档复制
- 源文档不可为归档的文档
- 当传入 original_document_id
时,代表文档进行更新操作,process_rule
为可填项目,不填默认使用源文档的分段方式
- 未传入 original_document_id
时,代表文档进行新增操作,process_rule
为必填
- indexing_technique
索引方式
- high_quality
高质量:使用 embedding 模型进行嵌入,构建为向量数据库索引
- economy
经济:使用 keyword table index 的倒排索引进行构建
- doc_form
索引内容的形式
- text_model
text 文档直接 embedding,经济模式默认为该模式
- hierarchical_model
parent-child 模式
- qa_model
Q&A 模式:为分片文档生成 Q&A 对,然后对问题进行 embedding
- doc_type
文档类型(选填)Type of document (optional)
- book
图书
文档记录一本书籍或出版物
- web_page
网页
网页内容的文档记录
- paper
学术论文/文章
学术论文或研究文章的记录
- social_media_post
社交媒体帖子
社交媒体上的帖子内容
- wikipedia_entry
维基百科条目
维基百科的词条内容
- personal_document
个人文档
个人相关的文档记录
- business_document
商业文档
商业相关的文档记录
- im_chat_log
即时通讯记录
即时通讯的聊天记录
- synced_from_notion
Notion同步文档
从Notion同步的文档内容
- synced_from_github
GitHub同步文档
从GitHub同步的文档内容
- others
其他文档类型
其他未列出的文档类型
- doc_metadata
文档元数据(如提供文档类型则必填
字段因文档类型而异
针对图书类型 For book
:
- title
书名
书籍的标题
- language
图书语言
书籍的语言
- author
作者
书籍的作者
- publisher
出版社
出版社的名称
- publication_date
出版日期
书籍的出版日期
- isbn
ISBN号码
书籍的ISBN编号
- category
图书分类
书籍的分类类别
针对网页类型 For web_page
:
- title
页面标题
网页的标题
- url
页面网址
网页的URL地址
- language
页面语言
网页的语言
- publish_date
发布日期
网页的发布日期
- author/publisher
作者/发布者
网页的作者或发布者
- topic/keywords
主题/关键词
网页的主题或关键词
- description
页面描述
网页的描述信息
请查看 [api/services/dataset_service.py](https://github.com/langgenius/dify/blob/main/api/services/dataset_service.py#L475) 了解各文档类型所需字段的详细信息。
针对"其他"类型文档,接受任何有效的JSON对象
- doc_language
在 Q&A 模式下,指定文档的语言,例如:English
、Chinese
- process_rule
处理规则
- mode
(string) 清洗、分段模式 ,automatic 自动 / custom 自定义
- rules
(object) 自定义规则(自动模式下,该字段为空)
- pre_processing_rules
(array[object]) 预处理规则
- id
(string) 预处理规则的唯一标识符
- 枚举:
- remove_extra_spaces
替换连续空格、换行符、制表符
- remove_urls_emails
删除 URL、电子邮件地址
- enabled
(bool) 是否选中该规则,不传入文档 ID 时代表默认值
- segmentation
(object) 分段规则
- separator
自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
- max_tokens
最大长度(token)默认为 1000
- parent_mode
父分段的召回模式 full-doc
全文召回 / paragraph
段落召回
- subchunk_segmentation
(object) 子分段规则
- separator
分段标识符,目前仅允许设置一个分隔符。默认为 ***
- max_tokens
最大长度 (token) 需要校验小于父级的长度
- chunk_overlap
分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
search_method
(string) 检索方法
- hybrid_search
混合检索
- semantic_search
语义检索
- full_text_search
全文检索
- reranking_enable
(bool) 是否开启rerank
- reranking_model
(object) Rerank 模型配置
- reranking_provider_name
(string) Rerank 模型的提供商
- reranking_model_name
(string) Rerank 模型的名称
- top_k
(int) 召回条数
- score_threshold_enabled
(bool)是否开启召回分数限制
- score_threshold
(float) 召回分数限制
high_quality
高质量
- economy
经济
only_me
仅自己
- all_team_members
所有团队成员
- partial_members
部分团队成员
vendor
上传文件
- external
外部知识库
book
图书 Book
- web_page
网页 Web page
- paper
学术论文/文章 Academic paper/article
- social_media_post
社交媒体帖子 Social media post
- wikipedia_entry
维基百科条目 Wikipedia entry
- personal_document
个人文档 Personal document
- business_document
商业文档 Business document
- im_chat_log
即时通讯记录 Chat log
- synced_from_notion
Notion同步文档 Notion document
- synced_from_github
GitHub同步文档 GitHub document
- others
其他文档类型 Other document types
book
:
- title
书名 Book title
- language
图书语言 Book language
- author
作者 Book author
- publisher
出版社 Publisher name
- publication_date
出版日期 Publication date
- isbn
ISBN号码 ISBN number
- category
图书分类 Book category
针对网页 For web_page
:
- title
页面标题 Page title
- url
页面网址 Page URL
- language
页面语言 Page language
- publish_date
发布日期 Publish date
- author/publisher
作者/发布者 Author or publisher
- topic/keywords
主题/关键词 Topic or keywords
- description
页面描述 Page description
请查看 [api/services/dataset_service.py](https://github.com/langgenius/dify/blob/main/api/services/dataset_service.py#L475) 了解各文档类型所需字段的详细信息。
针对"其他"类型文档,接受任何有效的JSON对象
mode
(string) 清洗、分段模式 ,automatic 自动 / custom 自定义
- rules
(object) 自定义规则(自动模式下,该字段为空)
- pre_processing_rules
(array[object]) 预处理规则
- id
(string) 预处理规则的唯一标识符
- 枚举:
- remove_extra_spaces
替换连续空格、换行符、制表符
- remove_urls_emails
删除 URL、电子邮件地址
- enabled
(bool) 是否选中该规则,不传入文档 ID 时代表默认值
- segmentation
(object) 分段规则
- separator
自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
- max_tokens
最大长度(token)默认为 1000
- parent_mode
父分段的召回模式 full-doc
全文召回 / paragraph
段落召回
- subchunk_segmentation
(object) 子分段规则
- separator
分段标识符,目前仅允许设置一个分隔符。默认为 ***
- max_tokens
最大长度 (token) 需要校验小于父级的长度
- chunk_overlap
分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
mode
(string) 清洗、分段模式 ,automatic 自动 / custom 自定义
- rules
(object) 自定义规则(自动模式下,该字段为空)
- pre_processing_rules
(array[object]) 预处理规则
- id
(string) 预处理规则的唯一标识符
- 枚举:
- remove_extra_spaces
替换连续空格、换行符、制表符
- remove_urls_emails
删除 URL、电子邮件地址
- enabled
(bool) 是否选中该规则,不传入文档 ID 时代表默认值
- segmentation
(object) 分段规则
- separator
自定义分段标识符,目前仅允许设置一个分隔符。默认为 \n
- max_tokens
最大长度(token)默认为 1000
- parent_mode
父分段的召回模式 full-doc
全文召回 / paragraph
段落召回
- subchunk_segmentation
(object) 子分段规则
- separator
分段标识符,目前仅允许设置一个分隔符。默认为 ***
- max_tokens
最大长度 (token) 需要校验小于父级的长度
- chunk_overlap
分段重叠指的是在对数据进行分段时,段与段之间存在一定的重叠部分(选填)
- doc_type
文档类型(选填)Type of document (optional)
- book
图书
文档记录一本书籍或出版物
- web_page
网页
网页内容的文档记录
- paper
学术论文/文章
学术论文或研究文章的记录
- social_media_post
社交媒体帖子
社交媒体上的帖子内容
- wikipedia_entry
维基百科条目
维基百科的词条内容
- personal_document
个人文档
个人相关的文档记录
- business_document
商业文档
商业相关的文档记录
- im_chat_log
即时通讯记录
即时通讯的聊天记录
- synced_from_notion
Notion同步文档
从Notion同步的文档内容
- synced_from_github
GitHub同步文档
从GitHub同步的文档内容
- others
其他文档类型
其他未列出的文档类型
- doc_metadata
文档元数据(如提供文档类型则必填
字段因文档类型而异
针对图书类型 For book
:
- title
书名
书籍的标题
- language
图书语言
书籍的语言
- author
作者
书籍的作者
- publisher
出版社
出版社的名称
- publication_date
出版日期
书籍的出版日期
- isbn
ISBN号码
书籍的ISBN编号
- category
图书分类
书籍的分类类别
针对网页类型 For web_page
:
- title
页面标题
网页的标题
- url
页面网址
网页的URL地址
- language
页面语言
网页的语言
- publish_date
发布日期
网页的发布日期
- author/publisher
作者/发布者
网页的作者或发布者
- topic/keywords
主题/关键词
网页的主题或关键词
- description
页面描述
网页的描述信息
请查看 [api/services/dataset_service.py](https://github.com/langgenius/dify/blob/main/api/services/dataset_service.py#L475) 了解各文档类型所需字段的详细信息。
针对"其他"类型文档,接受任何有效的JSON对象
content
(text) 文本内容/问题内容,必填
- answer
(text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
- keywords
(list) 关键字,非必填
content
(text) 文本内容/问题内容,必填
- answer
(text) 答案内容,非必填,如果知识库的模式为 Q&A 模式则传值
- keywords
(list) 关键字,非必填
- enabled
(bool) false/true,非必填
- regenerate_child_chunks
(bool) 是否重新生成子分段,非必填
search_method
(text) 检索方法:以下三个关键字之一,必填
- keyword_search
关键字检索
- semantic_search
语义检索
- full_text_search
全文检索
- hybrid_search
混合检索
- reranking_enable
(bool) 是否启用 Reranking,非必填,如果检索模式为 semantic_search 模式或者 hybrid_search 则传值
- reranking_mode
(object) Rerank 模型配置,非必填,如果启用了 reranking 则传值
- reranking_provider_name
(string) Rerank 模型提供商
- reranking_model_name
(string) Rerank 模型名称
- weights
(float) 混合检索模式下语意检索的权重设置
- top_k
(integer) 返回结果数量,非必填
- score_threshold_enabled
(bool) 是否开启 score 阈值
- score_threshold
(float) Score 阈值
code | status | message |
---|---|---|
no_file_uploaded | 400 | Please upload your file. |
too_many_files | 400 | Only one file is allowed. |
file_too_large | 413 | File size exceeded. |
unsupported_file_type | 415 | File type not allowed. |
high_quality_dataset_only | 400 | Current operation only supports 'high-quality' datasets. |
dataset_not_initialized | 400 | The dataset is still being initialized or indexing. Please wait a moment. |
archived_document_immutable | 403 | The archived document is not editable. |
dataset_name_duplicate | 409 | The dataset name already exists. Please modify your dataset name. |
invalid_action | 400 | Invalid action. |
document_already_finished | 400 | The document has been processed. Please refresh the page or go to the document details. |
document_indexing | 400 | The document is being processed and cannot be edited. |
invalid_metadata | 400 | The metadata content is incorrect. Please check and verify. |