Add file to RAG
Добавление файла в RAG
POST
https://gptunnel.ru/v1/database/file/add Добавляет файл в существующую базу данных. Файл будет автоматически обработан и включен в результаты поиска.
Headers
| Параметр | Тип | Описание |
|---|---|---|
Authorization* | string | API ключ |
Параметры запроса
| Параметр | Тип | Описание |
|---|---|---|
databaseId* | string | ID базы данных |
text* | string | Текст файла |
name | string | Имя файла |
chunkSize | number | Размер 1 фрагмента (по умолчанию 1024) |
overlapSize | number | Размер перекрытия (по умолчанию 0) |
splitVariable | string | Разделитель (если указан, chunkSize и overlapSize будут игнорироваться) |
Пример запроса
curl --request POST \ --url https://gptunnel.ru/v1/database/file/add \ --header 'Authorization: YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "databaseId": "669b1824c0d8dbde07d07d10", "text": "Hello world", "name": "Test file", "splitVariable": "|"}'import axios from 'axios'
const response = await axios({ method: 'POST', url: 'https://gptunnel.ru/v1/database/file/add', headers: { Authorization: 'YOUR_API_KEY', }, data: { databaseId: '669b1824c0d8dbde07d07d10', text: 'Hello world', name: 'Test file', splitVariable: '|', },})
console.log(response.data)import requests
response = requests.post( 'https://gptunnel.ru/v1/database/file/add', headers={'Authorization': 'YOUR_API_KEY'}, json={ 'databaseId': '669b1824c0d8dbde07d07d10', 'text': 'Hello world', 'name': 'Test file', 'splitVariable': '|', },)
print(response.json())Пример ответа
{ "id": "66a346f64dcb57627c03d596", "createDate": "2024-07-26T06:49:27.430Z", "status": "idle", "name": "Test file", "databaseId": "669b1824c0d8dbde07d07d10", "chunkSize": 1024, "overlapSize": 0, "splitVariable": "|", "tokenCount": 0, "tokenCost": "0", "error": null, "progress": null, "chunkCount": 0}{ "error": { "message": "Unauthorized", "type": "unauthorized_request_error", "param": null, "code": null }}