文件与集合

集合

查看 Markdown

Collections 为 xAI API 用户提供一套完善的工具和方法,可将企业需求和内部知识库无缝集成到 xAI API。无论是构建 RAG 应用,还是需要搜索大型文档集,Collections 都提供管理和查询内容所需的基础设施。


核心概念

用户可以在 Collections 服务中创建两种实体:

  • 文件,即用户上传的单个文件实体。

  • 集合,即一组关联的文件,并带有用于高效检索的嵌入索引。

    • 创建集合时,可选择为上传到该集合的所有文件自动生成嵌入。随后可以在多个集合的文件中执行语义搜索。

    • 单个文件可以属于多个集合。


可以执行的操作

使用 Collections,可以:

  • 创建集合,用于整理文档

  • 上传文档,支持多种格式(HTML、PDF、文本等)

  • 执行语义搜索,使用自然语言查询跨文档搜索

  • 配置分块和嵌入,以优化检索

  • 管理文档,包括列出、更新和删除


开始使用

选择使用 Collections 的方式:


元数据字段

Collections 支持 元数据字段,可附加到文档的结构化属性,用于增强检索和数据完整性:

  • 过滤检索,将搜索结果限定为符合特定条件的文档(例如 author="Sandra Kim"

  • 上下文嵌入,将元数据注入分块以提高检索准确度(例如在每个分块前添加文档标题)

  • 数据完整性约束,强制要求字段存在,或确保字段值在文档之间唯一

创建集合时,使用 requireduniqueinject_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


最后更新:2026 年 6 月 30 日