# 更新向量儲存中的文件內容

{% openapi src="<https://2492455604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTVKmtXKPeA8gAZJsuGLA%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media&token=3b4a9db2-4dd7-440f-b670-9555703d351d>" path="/vector-stores/{vector-store-id}/documents/{document-id}/" method="patch" %}
[rememberizer\_openapi.yml](https://2492455604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTVKmtXKPeA8gAZJsuGLA%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=3b4a9db2-4dd7-440f-b670-9555703d351d)
{% 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 %}
