# 输入类型

Canonical URL: https://developers.iagenify.com/zh/sdk/concepts/inputs/
Language: zh

输入是有类型的,可以是文字、图片、文档、录音、短片或一组段落。每个输入都可以作为值或 URL 提供。

Status: 7 types · content · url

## 形状 {#shape}

```javascript
{ type, content?, url?, mime? }
```

| 类型类型类型 | 携带内容 |
| --- | --- |
| 文字文字文字文字 | 字符串, 内容 |
| 图像图像图像图像 | 一张图片：url，或内容中的 base64 |
| 视频视频 | 一段短片：url，或内容中的 base64 |
| 音频 | 一段录音：url，或内容中的 base64 |
| 语音 | 音频是要转录而不是描述的音频 |
| 单行 | 排行或比较的文字,而不是作为文字 |
| file | a document such as a PDF: url only, never content |

## 提供输入的两种方式 {#sources}

```javascript
import { readFileSync } from "node:fs";

await assistant.generate({
  inputs: [
    { type: "text",  content: "What changed between these two?" },
    { type: "image", url: "https://example.com/before.png" },      // fetched for you
    { type: "image", content: base64Png, mime: "image/png" },      // already in hand
    // A local file is content too — read it yourself, there is no "path" input:
    { type: "image", content: readFileSync("./after.png").toString("base64"), mime: "image/png" },
  ],
});
```

> **过原始内容时设置 MIME**
>
> 使用 url 时，类型由服务器获取的内容推断得出。使用 content 中的 base64 时——无论是你自己的字节，还是刚刚读取的文件——都没有可供推断的依据，需要自行设置 mime。

## 顺序是意思 {#order}

输入按您给它们提供的顺序读取。在材料之前先回答问题,如果您想要阅读时要记住这个问题,然后是您想要一个未提前的描述。

## 段落不仅仅是更多的文字 {#passages}

几个 `text` 输入是一体要读取。 `passages` 是一个要排位或比较的单独项目组,这是调序调用所需要的。

```javascript
await reranker.generate({
  inputs: [
    { type: "text", content: "Which of these answers the question best?" },
    { type: "passages", content: [chunkA, chunkB, chunkC] },
  ],
});
```

```python
{"type": ..., "content": ..., "url": ..., "mime": ...}
```

```python
import base64
from pathlib import Path

assistant.generate(inputs=[
    {"type": "text", "content": "What changed between these two?"},
    {"type": "image", "url": "https://example.com/before.png"},          # fetched for you
    {"type": "image", "content": base64_png, "mime": "image/png"},       # already in hand
    # A local file is content too — read it yourself, there is no "path" input:
    {"type": "image", "content": base64.b64encode(Path("after.png").read_bytes()).decode(),
     "mime": "image/png"},
])
```

```python
reranker.generate(inputs=[
    {"type": "text", "content": "Which of these answers the question best?"},
    {"type": "passages", "content": [chunk_a, chunk_b, chunk_c]},
])
```
