はじめに

    API Endpoint
        https://yourendpoint.airealize.ai
                

これは、​ AIRealize を RESTAPI で使用するためのリファレンスマニュアルです。

API


    # Here is a curl example
    curl \
    -X POST {API_Endpoint}/api/document_chat \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type: application/json' \
    -d '{
      "document_id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"
      "messages": [
        {
          "role": "user", 
          "content": "What is this document about"
        }
      ],
      "locale": "ja-jp",
      "gpt_model": "gpt-4",
      "sse": "true"
    }'
                    

To inquiry a document, you need to make a POST call to the following url :
/api/document_chat



-------------------
| Request header |
-------------------
secret_key: your_api_key
Content-Type: application/json

-------------------
|   Request body  |
-------------------

{
    "document_id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
    "messages": [
        {
            "content": "Hello",
            "role": "user"
        }
    ],
    "locale": "ja-jp",
    "gpt_model": "gpt-4",
    "sse": true
}

--------------------
| Response example |
--------------------

SSE Response: 
{"event":"close","status":"approved","data":""}
{"event":"message","status":"pending","data":"."}
{"event":"message","status":"pending","data":"points"}
{"event":"message","status":"pending","data":"pain"}
{"event":"message","status":"pending","data":"RAG"}
{"event":"message","status":"pending","data":"about"}
{"event":"message","status":"pending","data":"discusses"}
{"event":"message","status":"pending","data":"document"}
{"event":"message","status":"pending","data":"This"}
{"event":"message","status":"pending","data":""}

HTTP Response:
200: {
    "content": "Hello",
    "role": "system"
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/json The content type of the request.

BODY PARAMETERS

Field Type Default Required Description
document_id String None False Document ID
locale Enum:
+ en-us
+ ja-jp
en-us False Language of the prompt
messages array True List of messages
gpt_model Enum:
+ gpt-3.5-turbo
+ gpt-4
None False GPT model used for a chat
sse String False False Enable/disable Server-Sent Events

RESPONSE

SSE Response:

{"event":"message","status":"pending","data":"Hello world"}

HTTP Response

Field Type Default Required Description
role Enum:
+ user
+ system
system False Role of the message
content string True Content of the message


    # Here is a curl example
    curl \
    -X POST {API_Endpoint}/api/document/upload \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -F 'file=@"/C:/Users/Document/sample.docx"' \
    -F 'name_file="sample.docx"' \
    -F 'access_type="only_me"'
                    

To upload a document, you need to make a POST call to the following url :
/api/document/upload



-------------------
| Request header |
-------------------
secret_key: your_api_key
Content-Type: application/x-www-form-urlencoded

-------------------
| Request body |
-------------------

{
    "access_type": "only_me",
    "file": "File content",
    "name_file": "Document name"
}

--------------------
| Response example |
--------------------

200: {
    "msg": "Upload document successfully!"
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/x-www-form-urlencoded The content type of the request.

BODY PARAMETERS

Field Type Default Required Description
name_file string True Document name
access_type only_me False Document access type
file True File content

RESPONSE

200

Field Type Default Required Description
msg string True Message response


    # Here is a curl example
    curl \
    -X GET {API_Endpoint}/api/documents?page=0&page_size=10 \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type :application/json'
                    

To get a list of registered documents you need, to make a GET call to the following url :
/api/documents



-------------------
| Request header |
-------------------
secret_key: your_api_key
Content-Type: application/json

--------------------
| Response example |
--------------------

200: {
    "data": [
        {
            "created_at": "2022-01-01T00:00:00",
            "doc_name": "Document name",
            "doc_type": "Document type",
            "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
            "is_deleted": false,
            "overview": "Document overview content",
            "path": "Document path",
            "status": "IN_PROCESS",
            "updated_at": "2022-01-01T00:00:00",
            "username": "username"
        }
    ],
    "message": "Success",
    "page": 1,
    "page_size": 10,
    "status": 200,
    "total_page": 1
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/json The content type of the request.

QUERY PARAMETERS

Field Type Default Required Description
page integer True Page number
page_size integer True Page size

RESPONSE

200

Field Type Default Required Description
status String True Status code
data array True List of documents
message String None False Message response
page integer True Page number
page_size integer True Page size
total_page integer True Total page


    # Here is a curl example
    curl \
    -X GET {API_Endpoint}/api/document?id=a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type :application/json'
                    

To get a document information, you need to make a GET call to the following url :
/api/document



-------------------
| Request header |
-------------------
secret_key: your_api_key
Content-Type: application/json

--------------------
| Response example |
--------------------

200: {
    "data": {
        "created_at": "2022-01-01T00:00:00",
        "doc_name": "Document name",
        "doc_type": "Document type",
        "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
        "is_deleted": false,
        "overview": "Document overview content",
        "path": "Document path",
        "status": "IN_PROCESS",
        "updated_at": "2022-01-01T00:00:00",
        "username": "username"
    },
    "message": "Success",
    "status": 200
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/json The content type of the request.

QUERY PARAMETERS

Field Type Default Required Description
id string True Document ID

RESPONSE

200

Field Type Default Required Description
status String True Status code
data True Document details
message String None False Message response


    # Here is a curl example
    curl \
    -X PUT {API_Endpoint}/api/document \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type :application/json'
                    

To edit a document information, you need to make a PUT call to the following url :
/api/document



-------------------
| Request header |
-------------------
secret_key: your_api_key
Content-Type :application/json

-------------------
|   Request body  |
-------------------

{
    "doc_name": "Document name | None",
    "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
    "overview": "Document overview content | None"
}

--------------------
| Response example |
--------------------

200: {
    "data": [
        {
            "created_at": "2022-01-01T00:00:00",
            "doc_name": "Document name",
            "doc_type": "Document type",
            "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
            "is_deleted": false,
            "overview": "Document overview content",
            "path": "Document path",
            "status": "IN_PROCESS",
            "updated_at": "2022-01-01T00:00:00",
            "username": "username"
        }
    ],
    "message": "Success",
    "status": 200
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/json The content type of the request.

BODY PARAMETERS

Field Type Default Required Description
id string True Document ID
doc_name String None False Document name
overview String None False Document overview content

RESPONSE

200

Field Type Default Required Description
status String True Status code
data String None False Data response
message String None False Message response


    # Here is a curl example
    curl \
    -X DELETE {API_Endpoint}/api/document?id=7056809a-85fe-4032-b9ee-ff8982daae2d \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type :application/json'
                    

To delete a registerd document, you need to make a DELETE call to the following url :
/api/document



-------------------
| Request header |
-------------------
secret_key: {your_api_key}
Content-Type :application/json

--------------------
| Response example |
--------------------

200: {
    "data": null,
    "message": "Delete document successfully!",
    "status": 200
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/json The content type of the request.

QUERY PARAMETERS

Field Type Default Required Description
id string True Document ID

RESPONSE

200

Field Type Default Required Description
status String True Status code
data String None False Data response
message String None False Message response


    # Here is a curl example
    curl \
    -X POST {API_Endpoint}/api/chatgpt \
    -H 'secret_key: {your_api_key}' \
    -H 'Content-Type :application/json' \
    -d '{
      "messages": [
        {
          "role": "user", 
          "content": "Hello"
        }
      ],
      "locale": "ja-jp",
      "gpt_model": "gpt-4",
      "sse": "true"
    }'
                    

To get completion from ChatGPT, you need to make a POST call to the following url :
/api/chatgpt



-------------------
| Request header |
-------------------
secret_key: your_api_key
Content-Type: application/json

-------------------
|   Request body  |
-------------------

{
    "messages": [
        {
            "content": "Hello",
            "role": "user"
        }
    ],
    "locale": "ja-jp",
    "gpt_model": "gpt-4",
    "sse": true
}

--------------------
| Response example |
--------------------

SSE Response: 
{"event":"close","status":"approved","data":""}
{"event":"message","status":"pending","data":"!"}
{"event":"message","status":"pending","data":"there"}
{"event":"message","status":"pending","data":"Hello"}
{"event":"message","status":"pending","data":""}


200: {
    "content": "Hello",
    "role": "bot"
}
400: {
    "description": "Bad Request"
}
401: {
    "description": "Unauthorized"
}
403: {
    "description": "Forbidden"
}
404: {
    "description": "Not Found"
}
                    

HEADER PARAMETERS

Field Type Description
secret_key String Your API key.
Content-Type application/json The content type of the request.

BODY PARAMETERS

Field Type Default Required Description
messages array True List of messages
locale Enum:
+ en-us
+ ja-jp
en-us False Language of the prompt
gpt_model Enum:
+ gpt-3.5-turbo
+ gpt-4
None False GPT model used for a chat
sse String False False Enable/disable Server-Sent Events

RESPONSE

SSE Response:

{"event":"message","status":"pending","data":"Hello world"}

HTTP Response

Description: Base class for the response of the prompt chat
Note: use company_chat.py to get the response

Field Type Default Required Description
role Enum:
+ user
+ system
system False Role of the message
content string True Content of the message