將新文本文件添加到向量存儲¶
POST /vector-stores/{vector-store-id}/documents/create¶
Create a new text document in a vector store.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
vector-store-id |
path | string | yes | The ID of the vector store. |
x-api-key |
header | string | yes | The API key for authentication. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | The name of the document. | |
text |
string | The text content of the document. |
Responses
201— Document created successfully.
示例請求¶
curl -X POST
https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/create
-H "x-api-key: YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"name": "產品概述",
"text": "我們的產品是一個創新的解決方案,用於管理向量嵌入。它提供與您現有系統的無縫集成,並提供強大的語義搜索功能。"
}'
Info
將 YOUR_API_KEY 替換為您的實際向量存儲 API 金鑰,並將 vs_abc123 替換為您的向量存儲 ID。
const addTextDocument = async (vectorStoreId, name, text) => {
const response = await fetch(`https://api.rememberizer.ai/api/v1/vector-stores/${vectorStoreId}/documents/create`, {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: name,
text: text
})
});
const data = await response.json();
console.log(data);
};
addTextDocument(
'vs_abc123',
'產品概述',
'我們的產品是一個創新的解決方案,用於管理向量嵌入。它提供與您現有系統的無縫集成,並提供強大的語義搜索功能。'
);
Info
將 YOUR_API_KEY 替換為您的實際向量存儲 API 金鑰,並將 vs_abc123 替換為您的向量存儲 ID。
import requests
import json
def add_text_document(vector_store_id, name, text):
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"name": name,
"text": text
}
response = requests.post(
f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/create",
headers=headers,
data=json.dumps(payload)
)
data = response.json()
print(data)
add_text_document(
'vs_abc123',
'產品概述',
'我們的產品是一個創新的解決方案,用於管理向量嵌入。它提供與您現有系統的無縫集成,並提供強大的語義搜索功能。'
)
Info
將 YOUR_API_KEY 替換為您的實際向量存儲 API 金鑰,並將 vs_abc123 替換為您的向量存儲 ID。
路徑參數¶
| 參數 | 類型 | 描述 |
|---|---|---|
| vector-store-id | 字串 | 必填。 要將文件添加到的向量存儲的 ID。 |
請求主體¶
| 參數 | 類型 | 描述 |
|---|---|---|
| name | 字串 | 必填。 文件的名稱。 |
| text | 字串 | 必填。 文件的文本內容。 |
回應格式¶
{
"id": 1234,
"name": "產品概覽",
"type": "text/plain",
"vector_store": "vs_abc123",
"size": 173,
"status": "處理中",
"processing_status": "排隊中",
"indexed_on": null,
"status_error_message": null,
"created": "2023-06-15T10:15:00Z",
"modified": "2023-06-15T10:15:00Z"
}
認證¶
此端點需要使用 x-api-key 標頭中的 API 金鑰進行認證。
錯誤回應¶
| 狀態碼 | 描述 |
|---|---|
| 400 | 錯誤的請求 - 缺少必要欄位或格式無效 |
| 401 | 未授權 - API 金鑰無效或缺失 |
| 404 | 找不到 - 向量儲存庫未找到 |
| 500 | 內部伺服器錯誤 |
此端點允許您直接將文本內容添加到您的向量儲存庫中。這對於存儲可能不存在於文件格式中的信息特別有用,例如產品描述、知識庫文章或自定義內容。文本將自動處理為向量嵌入,使其可以通過語義相似性進行搜索。