1. Questions
ChatDOC
  • Documents
    • Upload Document
      POST
    • Upload Document
      POST
    • Get Document
      GET
    • Delete Document
      DELETE
    • Download Document
      GET
  • Collections
    • Create Collection
      POST
    • Clone Document To Collection
      POST
  • Questions
    • Get Suggested Questions
      GET
    • Ask Question
      POST
    • Get Question
      GET
    • Ask Question With Multiple Documents
      POST
  • Users
    • Get Quota
      GET
  • Schemas
    • Schemas
      • APIAIModelEnum
      • APICloneReq
      • APICollectionOrUploadResp
      • APIPackageInfoResp
      • APIUploadResp
      • Body_Upload_Document_documents_upload_post
      • ChatMessage
      • ChatRoleEnum
      • CollectionReq
      • DocumentErrorMessage
      • DocumentStatus
      • HTTPValidationError
      • HtmlSelectedMeta
      • InteractionType
      • PDFViewerRect
      • PackageDataResp
      • PackageQuotaResp
      • QuestionReq
      • QuestionReqWithUploadIds
      • QuestionResp
      • SelectedMeta
      • SelectedMetaWithUploadId
      • UploadOcrType
      • UploadPackageType
      • UploadType
      • ValidationError
      • WebsiteReq
  1. Questions

Ask Question

Develop Env
https://dev.your-api-server.com
Develop Env
https://dev.your-api-server.com
POST
/questions
Chat with the document, response in server-sent events mode by default, you can change it through stream parameter.
Consume one question quota whether it's upon single document or collection.
Response:
if document is pdf/doc/docx format, structure is as follows:
{
    "data": {
        "answer": "answer to the question",
        "id": question_id,
        "source_info": [
            {
                # key: page number
                # value: rects
                '0': [[38.1063, 557.8058, 553.9003, 584.0043]]
            },
            {'1': [[38.0, 152.3994, 523.6151, 178.6392]], 'upload_id': 'xxxx'},
            {'0': [[38.0, 758.0623, 537.0082, 784.0]], 'upload_id': 'xxxx'},
            ...
        ]
    }
}
if document is md/epub/txt/website format, structure is as follows:
{
    "data": {
        "answer": "answer to the question",
        "id": question_id,
        "source_info": [
            {
            # key: element data-index
            # value: element xpath
            198: [{xpath: "/html/body/div/div[199]"}]
            },
            {
            "material": "", # selected text with HTML tags
            "indexes": [
                3,
                4,
                5,
                6
            ],
            "focusNode": "div[1]/p[5]/text()[1]",
            "upload_id": "903d971d-8250-47cc-a649-4b6ca35032dc",
            "anchorNode": "div[1]/p[2]/text()[1]",
            "focusOffset": "225",
            "anchorOffset": "2"
        }
            ...
        ]
    }
}
answer: chunks of answer, may be Markdown format to support rich text, for example: Tables. For detailed_citation answer, the span tag chunk may be as follows:
autobiography captured the pre-Nazi Europe[<span data-index="0">1</span>]
The tag attr data-index is the index of the source in source_info array, which is used to highlight the source of the previous answer sentences in your PDF viewer. The highlighting method is same as source_info, and just use slice of source_info array as parameter.
id: id of the question, you can use it to GET /questions/{question_id} later.
Please note: you should store id in your database, because we don't have a GET /questions/list API to list all questions for now.
source_info: only responses in the last chunk of server-sent events mode, may be an empty list. So if the last chunk doesn't contain source_info attr, it means error occurred. Page number may not be ordered, you can use this information to highlight the source of specific upload_id document of the answer in your PDF viewer, by
calling drawSources method of our DOCViewerSDK, and converting source_info to Source parameter.

Request

Body Params application/json

Examples

Responses

🟢200Successful Response
application/json
Body

🟠422Validation Error
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://dev.your-api-server.com/questions' \
--header 'Content-Type: application/json' \
--data-raw '{
    "upload_id": "stringstringstringstringstringstring",
    "question": "string",
    "stream": true,
    "selected_meta": {
        "material": "string",
        "upload_id": "stringstringstringstringstringstring",
        "rects": [
            {
                "pageNumber": 1,
                "outline": [
                    1,
                    1,
                    1,
                    1
                ]
            }
        ]
    },
    "history": [],
    "search_entire_doc": true,
    "detailed_citation": false,
    "language": "string",
    "model_type": "gpt-3.5-turbo"
}'
Response Response Example
200 - Example 1
null
Modified at 2024-07-26 06:57:23
Previous
Get Suggested Questions
Next
Get Question
Built with