feat(API): Ingest plain text (#1417)

* Add ingest/text route to ingest plain text

* Add new ingest text test and adapt ingest/file ones

* Include new API in docs

* Remove duplicated logic
This commit is contained in:
Iván Martínez
2023-12-18 21:47:05 +01:00
committed by GitHub
parent 059f35840a
commit 6eeb95ec7f
6 changed files with 198 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ from pathlib import Path
from fastapi.testclient import TestClient
from private_gpt.server.ingest.ingest_router import IngestResponse
from tests.fixtures.ingest_helper import IngestHelper
@@ -34,3 +35,12 @@ def test_ingest_list_returns_something_after_ingestion(
assert (
count_ingest_after == count_ingest_before + 1
), "The temp doc should be returned"
def test_ingest_plain_text(test_client: TestClient) -> None:
response = test_client.post(
"/v1/ingest/text", json={"file_name": "file_name", "text": "text"}
)
assert response.status_code == 200
ingest_result = IngestResponse.model_validate(response.json())
assert len(ingest_result.data) == 1