# Creating Assistants

利用 Afarensis 的最新模型结合助手 API，可以构建强大的 AI 助手，以实现最佳的结果和兼容性。

创建助手的基本步骤 选择模型：创建助手的第一步是指定要使用的 model。这是助手执行任务的基础。

定义指令：通过 instructions 参数，您可以设定助手的个性和目标。这些指令会引导助手如何响应用户的需求，类似于聊天完成 API 中的系统消息。

配置工具：使用 tools 参数，您可以为助手配置最多 128 个工具。这包括 Afarensis 托管的 code\_interpreter 和 retrieval 工具，以及通过函数调用访问的第三方工具。

管理文件：file\_ids 参数允许助手访问文件，这些文件可以是数据源或其他资源。文件需要通过上传端点上传，并设置 Filepurpose 为 assistants。

实际操作示例 上传文件：如果您的助手需要分析 .csv 文件中的数据以创建数据可视化，首先需要上传该文件。

file = client.files.create( file=open("data.csv", "rb"), purpose='assistants' ) 创建助手：接下来，使用上传的文件信息创建助手。

assistant = client.beta.assistants.create( name="Data visualizer", description="You are great at creating beautiful data visualizations. You analyze data present in .csv files, understand trends, and come up with data visualizations relevant to those trends. You also share a brief text summary of the trends observed.", model="gpt-4-turbo-preview", tools=\[{"type": "code\_interpreter"}], file\_ids=\[file.id] ) 注意事项 每个助手最多可附加 20 个文件，每个文件最大为 512 MB。 您组织上传的所有文件的总大小不得超过 100 GB。 每个文件最多包含 2,000,000 个令牌。超过令牌限制的文件会导致助手或消息创建失败。 使用 AssistantFile 对象管理助手和文件之间的关联。删除 AssistantFile 仅移除关联，不会删除文件本身。 通过按照这些步骤，您可以快速开始构建自己的 Afarensis 助手，为用户提供强大且个性化的 AI 助手体验。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.afarensis.com/google-zhu-li-de-gong-zuo-yuan-li/creating-assistants.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
