文件与集合

Collections

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

核心概念

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

  • File,用户上传的单个文件 entity。

  • Collection,一组关联在一起的文件,并具有用于高效检索的 embedding index。

    • 创建 collection 时,可以选择为上传到该 collection 的所有文件自动生成 embedding。随后可以跨多个 collection 中的文件执行 semantic search。

    • 单个文件可以属于多个 collection。

可以执行的操作

使用 Collections,可以:

  • 创建 collection,用于整理文档

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

  • 执行 semantic search,使用自然语言 query 跨文档搜索

  • 配置 chunking 和 embedding,以优化检索

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

开始使用

选择使用 Collections 的方式:

Metadata 字段

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

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

  • Contextual embedding,将 metadata 注入 chunk 以提高检索准确度(例如在每个 chunk 前添加文档标题)

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

创建 collection 时,使用 requireduniqueinject_into_chunk 等选项定义 metadata 字段,控制 metadata 的验证方式以及搜索时的使用方式。

进一步了解 metadata 字段 →

Usage 限制

要上传文件并将其添加到 collection,账户中必须有 credit。

最大文件大小:100MB

如需提高这些限制,请 联系我们

数据隐私

我们不会将存储在 Collections 中的用户数据用于 model training。

支持的 MIME Type

我们支持任何使用 UTF-8 编码的文本文件,并为特定 MIME type 提供专用的文件转换和 chunking 技术。

以下是受支持 MIME type 的非完整列表:

  • 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