文件与集合
集合
Collections 为 xAI API 用户提供了一套强大的工具和方法,使他们能够无缝地将企业需求和内部知识库与 xAI API 集成。无论您是构建 RAG 应用程序,还是需要在大型文档集中进行搜索,Collections 都提供了管理和查询您内容的基础设施。
NOTE
在找 Files? 如果您想将文件直接附加到聊天消息中以提供对话上下文,请参阅 Files。Collections 是不同的——它们提供持久的文档存储,并支持跨多个文档的语义搜索。
核心概念
在 Collections 服务中,用户可以创建两种实体:
- File — 用户上传的单个文件实体。
- Collection — 链接在一起的文件组,带有嵌入索引以实现高效检索。
- 当您创建集合时,可以选择为上传到该集合的任何文件自动生成嵌入。然后,您可以在多个集合中的文件之间执行语义搜索。
- 单个文件可以属于多个集合。
您可以做什么
使用 Collections,您可以:
- 创建集合 来组织您的文档
- 上传各种格式 的文档(HTML、PDF、文本等)
- 使用自然语言查询 在您的文档中进行语义搜索
- 配置分块和嵌入 以优化检索
- 管理文档,包括列出、更新和删除它们
入门指南
选择您想要使用 Collections 的方式:
元数据字段
Collections 支持元数据字段——您可以附加到文档上的结构化属性,以增强检索和数据完整性:
- 过滤检索 — 将搜索结果缩小到符合特定条件的文档(例如
author="Sandra Kim") - 上下文嵌入 — 将元数据注入到分块中以提高检索准确性(例如,在每个分块前添加文档标题)
- 数据完整性约束 — 在文档间强制执行必填字段或唯一性
创建集合时,使用 required、unique 和 inject_into_chunk 等选项定义元数据字段,以控制元数据在搜索过程中的验证和使用方式。
使用限制
要能够上传文件并将其添加到集合中,您的账户必须有积分。
最大文件大小:100MB
请联系我们 联系我们 来提高这些限制中的任何一个。
数据隐私
我们不会将存储在 Collections 中的用户数据用于模型训练目的。
支持的 MIME 类型
虽然我们支持任何 UTF-8 编码的文本文件,但对于某些 MIME 类型,我们也有特殊的文件转换和分块技术。
以下是我们支持的 MIME 类型的不完整列表:
- application/csv
- application/dart
- application/ecmascript
- application/epub
- application/epub+zip
- application/json
- application/ms-java
- application/msword
- application/pdf
- application/typescript
- application/vnd.adobe.pdf
- application/vnd.curl
- application/vnd.dart
- application/vnd.jupyter
- application/vnd.ms-excel
- application/vnd.ms-outlook
- application/vnd.oasis.opendocument.text
- application/vnd.openxmlformats-officedocument.presentationml.presentation
- application/vnd.openxmlformats-officedocument.presentationml.slide
- application/vnd.openxmlformats-officedocument.presentationml.slideshow
- application/vnd.openxmlformats-officedocument.presentationml.template
- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
- application/vnd.openxmlformats-officedocument.spreadsheetml.template
- application/vnd.openxmlformats-officedocument.wordprocessingml.document
- application/x-csh
- application/x-epub+zip
- application/x-hwp
- application/x-hwp-v5
- application/x-latex
- application/x-pdf
- application/x-php
- application/x-powershell
- application/x-sh
- application/x-shellscript
- application/x-tex
- application/x-zsh
- application/xhtml
- application/xml
- application/zip
- text/cache-manifest
- text/calendar
- text/css
- text/csv
- text/html
- text/javascript
- text/jsx
- text/markdown
- text/n3
- text/php
- text/plain
- text/rtf
- text/tab-separated-values
- text/troff
- text/tsv
- text/tsx
- text/turtle
- text/uri-list
- text/vcard
- text/vtt
- text/x-asm
- text/x-bibtex
- text/x-c
- text/x-c++hdr
- text/x-c++src
- text/x-chdr
- text/x-coffeescript
- text/x-csh
- text/x-csharp
- text/x-csrc
- text/x-d
- text/x-diff
- text/x-emacs-lisp
- text/x-erlang
- text/x-go
- text/x-haskell
- text/x-java
- text/x-java-properties
- text/x-java-source
- text/x-kotlin
- text/x-lisp
- text/x-lua
- text/x-objcsrc
- text/x-pascal
- text/x-perl
- text/x-perl-script
- text/x-python
- text/x-python-script
- text/x-r-markdown
- text/x-rst
- text/x-ruby-script
- text/x-rust
- text/x-sass
- text/x-scala
- text/x-scheme
- text/x-script.python
- text/x-scss
- text/x-sh
- text/x-sql
- text/x-swift
- text/x-tcl
- text/x-tex
- text/x-vbasic
- text/x-vcalendar
- text/xml
- text/xml-dtd
- text/yaml