From ceff618e5d19a41be2f47e0e535c9acdde98be44 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Mon, 30 Oct 2023 01:18:52 +0300 Subject: [PATCH] Update API-docs.md --- docs/pages/Developing/API-docs.md | 106 ++++++++++++++++-------------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/docs/pages/Developing/API-docs.md b/docs/pages/Developing/API-docs.md index e8ee521f..b57f6b1b 100644 --- a/docs/pages/Developing/API-docs.md +++ b/docs/pages/Developing/API-docs.md @@ -10,14 +10,16 @@ This endpoint is used to request answers to user-provided questions. **Request:** -Method: POST -Headers: Content-Type should be set to "application/json; charset=utf-8" -Request Body: JSON object with the following fields: -* **question:** The user's question -* **history:** (Optional) Previous conversation history -* **api_key:** Your API key -* **embeddings_key:** Your embeddings key -* **active_docs:** The location of active documentation +**Method**: `POST` + +**Headers**: Content-Type should be set to `application/json; charset=utf-8` + +**Request Body**: JSON object with the following fields: +* `question` — The user's question. +* `history` — (Optional) Previous conversation history. +* `api_key`— Your API key. +* `embeddings_key` — Your embeddings key. +* `active_docs` — The location of active documentation. Here is a JavaScript Fetch Request example: ```js @@ -36,7 +38,7 @@ fetch("http://127.0.0.1:5000/api/answer", { **Response** -In response, you will get a JSON document containing the answer,query and the result: +In response, you will get a JSON document containing the `answer`, `query` and `result`: ```json { "answer": "Hi there! How can I help you?\n", @@ -53,9 +55,10 @@ This endpoint will make sure documentation is loaded on the server (just run it **Request:** -Headers: Content-Type should be set to "application/json; charset=utf-8" -Request Body: JSON object with the field: -* **docs:** The location of the documentation +**Headers**: Content-Type should be set to `application/json; charset=utf-8` + +**Request Body**: JSON object with the field: +* `docs` — The location of the documentation: ```js // answer (POST http://127.0.0.1:5000/api/docs_check) fetch("http://127.0.0.1:5000/api/docs_check", { @@ -71,7 +74,7 @@ fetch("http://127.0.0.1:5000/api/docs_check", { **Response:** -In response, you will get a JSON document like this one indicating whether the documentation exists or not.: +In response, you will get a JSON document like this one indicating whether the documentation exists or not: ```json { "status": "exists" @@ -86,19 +89,25 @@ This endpoint provides information about available vectors and their locations w **Request:** -Method: GET +**Method**: `GET` **Response:** Response will include: -`date`, `description`, `docLink`, `fullName`, `language`, `location` (local or docshub), `model`, `name`, `version`. - +* `date` +* `description` +* `docLink` +* `fullName` +* `language` +* `location` (local or docshub) +* `model` +* `name` +* `version` Example of JSON in Docshub and local: image - ### 4. /api/upload **Description:** @@ -106,8 +115,8 @@ This endpoint is used to upload a file that needs to be trained, response is JSO **Request:** -Method: POST -Request Body: A multipart/form-data form with file upload and additional fields, including "user" and "name." +**Method**: `POST` +**Request Body**: A multipart/form-data form with file upload and additional fields, including `user` and `name`. HTML example: @@ -134,8 +143,8 @@ JSON response with a status and a task ID that can be used to check the task's p This endpoint is used to get the status of a task (`task_id`) from `/api/upload` **Request:** -Method: GET -Query Parameter: task_id (task ID to check) +**Method**: `GE`T +**Query Parameter**: `task_id` (task ID to check) **Sample JavaScript Fetch Request:** ```js @@ -155,33 +164,32 @@ fetch("http://localhost:5001/api/task_status?task_id=YOUR_TASK_ID", { There are two types of responses: 1. While the task is still running, the 'current' value will show progress from 0 to 100. - -```json -{ - "result": { - "current": 1 - }, - "status": "PROGRESS" -} -``` + ```json + { + "result": { + "current": 1 + }, + "status": "PROGRESS" + } + ``` 2. When task is completed: -```json -{ - "result": { - "directory": "temp", - "filename": "install.rst", - "formats": [ - ".rst", - ".md", - ".pdf" - ], - "name_job": "somename", - "user": "local" - }, - "status": "SUCCESS" -} -``` + ```json + { + "result": { + "directory": "temp", + "filename": "install.rst", + "formats": [ + ".rst", + ".md", + ".pdf" + ], + "name_job": "somename", + "user": "local" + }, + "status": "SUCCESS" + } + ``` ### 6. /api/delete_old **Description:** @@ -190,7 +198,8 @@ This endpoint is used to delete old Vector Stores. **Request:** -Method: GET +**Method**: `GET` + ```js // Task status (GET http://127.0.0.1:5000/api/docs_check) fetch("http://localhost:5001/api/task_status?task_id=b2d2a0f4-387c-44fd-a443-e4fe2e7454d1", { @@ -205,7 +214,8 @@ fetch("http://localhost:5001/api/task_status?task_id=b2d2a0f4-387c-44fd-a443-e4f ``` **Response:** -JSON response indicating the status of the operation. +JSON response indicating the status of the operation: + ```json { "status": "ok" } ```