# 更新向量存储中文件的内容

{% openapi src="<https://1371168417-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gvX7KIUy0DhcQETj8Ux%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media&token=cce1ab0d-330f-4bed-b7da-5635aaf25472>" path="/vector-stores/{vector-store-id}/documents/{document-id}/" method="patch" %}
[rememberizer\_openapi.yml](https://1371168417-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gvX7KIUy0DhcQETj8Ux%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=cce1ab0d-330f-4bed-b7da-5635aaf25472)
{% endopenapi %}

## 示例请求

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X PATCH \
  https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/1234/ \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "更新的产品概述"
  }'
```

{% hint style="info" %}
将 `YOUR_API_KEY` 替换为您的实际向量存储 API 密钥，将 `vs_abc123` 替换为您的向量存储 ID，将 `1234` 替换为文档 ID。
{% endhint %}
{% endtab %}

{% tab title="JavaScript" %}

```javascript
const updateDocument = async (vectorStoreId, documentId, newName) => {
  const response = await fetch(`https://api.rememberizer.ai/api/v1/vector-stores/${vectorStoreId}/documents/${documentId}/`, {
    method: 'PATCH',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: newName
    })
  });
  
  const data = await response.json();
  console.log(data);
};

updateDocument('vs_abc123', 1234, '更新的产品概述');
```

{% hint style="info" %}
将 `YOUR_API_KEY` 替换为您的实际向量存储 API 密钥，将 `vs_abc123` 替换为您的向量存储 ID，将 `1234` 替换为文档 ID。
{% endhint %}
{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def update_document(vector_store_id, document_id, new_name):
    headers = {
        "x-api-key": "YOUR_API_KEY",
        "Content-Type": "application/json"
    }
    
    payload = {
        "name": new_name
    }
    
    response = requests.patch(
        f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/{document_id}/",
        headers=headers,
        data=json.dumps(payload)
    )
    
    data = response.json()
    print(data)

update_document('vs_abc123', 1234, '更新的产品概述')
```

{% hint style="info" %}
将 `YOUR_API_KEY` 替换为您的实际向量存储 API 密钥，将 `vs_abc123` 替换为您的向量存储 ID，将 `1234` 替换为文档 ID。
{% endhint %}
{% endtab %}
{% endtabs %}

## 路径参数

| 参数              | 类型  | 描述                     |
| --------------- | --- | ---------------------- |
| vector-store-id | 字符串 | **必填。** 包含文档的向量存储的 ID。 |
| document-id     | 整数  | **必填。** 要更新的文档的 ID。    |

## 请求体

```json
{
  "name": "更新的产品概述"
}
```

| 参数   | 类型  | 描述      |
| ---- | --- | ------- |
| name | 字符串 | 文档的新名称。 |

## 响应格式

```json
{
  "id": 1234,
  "name": "更新的产品概述",
  "type": "text/plain",
  "vector_store": "vs_abc123",
  "size": 173,
  "status": "已索引",
  "processing_status": "已完成",
  "indexed_on": "2023-06-15T10:30:00Z",
  "status_error_message": null,
  "created": "2023-06-15T10:15:00Z",
  "modified": "2023-06-15T11:45:00Z"
}
```

## 认证

此端点需要使用 `x-api-key` 头中的 API 密钥进行认证。

## 错误响应

| 状态码 | 描述                |
| --- | ----------------- |
| 400 | 错误请求 - 请求格式无效     |
| 401 | 未授权 - API 密钥无效或缺失 |
| 404 | 未找到 - 向量存储或文档未找到  |
| 500 | 服务器内部错误           |

此端点允许您更新向量存储中文档的元数据。目前，您只能更新文档的名称。这对于改善文档的组织和可发现性非常有用，而无需重新上传文档。

{% hint style="info" %}
注意：此端点仅更新文档的元数据，而不更新其内容。要更新内容，您需要删除现有文档并上传新文档。
{% endhint %}
