# 문서 QA

## 문서 업로드

질의응답하고 싶은 PDF 문서를 가져와 딥서치에 업로드 할 수 있습니다. 문서 업로드할 때 URL로 업로드하거나 PDF 파일을 직접 업로드할 수 있습니다.  &#x20;

#### 1. URL로 문서 업로드

## URL로 PDF 문서 업로드하기

<mark style="color:green;">`POST`</mark> `https://api.deepsearch.com/note/v1/pdf/upload`

질의응답하고 싶은 PDF 문서 URL를 가져와서 딥서치에 업로드 할 수 있습니다.&#x20;

#### Request Body

| Name                                  | Type   | Description |
| ------------------------------------- | ------ | ----------- |
| url<mark style="color:red;">\*</mark> | String | 문서 url      |
| category                              | String | 문서 카테고리     |
| company\_name                         | String | 문서에 관련 기업명  |
| company\_symbol                       | String | 문서에 관련 기업코드 |

{% tabs %}
{% tab title="200: OK 업로드 성공" %}

```json
{
    "success": true,
    "summary": "success",
    "uid": {{생성한 챗uid}},
    "uid_str": "{{생성한 챗uid}}",
    "url": "{{문서 url}}"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 업로드 실패" %}

```json
{
    "detail": {
        "code": 70004,
        "msg": "failed_to_upload"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Insufficient PDF 내용" %}

```json
{
    "detail": {
        "code": 70004,
        "msg": "document_insufficient_data"
    }
}
```

{% endtab %}
{% endtabs %}

#### 2. PDF파일로 문서 업로드

## 파일로 PDF 문서 업로드하기

<mark style="color:green;">`POST`</mark> `https://api.deepsearch.com/note/v1/pdf/upload`

질의응답하고 싶은 PDF 문서 파일를 가져와서 딥서치에 업로드 할 수 있습니다. 파일 업로드 할 때 request body는 `form-data`로 사용합니다.

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| file<mark style="color:red;">\*</mark> | File   | PDF 파일      |
| category                               | String | 문서 카테고리     |
| company\_name                          | String | 문서에 관련 기업명  |
| company\_symbol                        | String | 문서에 관련 기업코드 |

{% tabs %}
{% tab title="200: OK API 결과" %}

```
{
    "success": true,
    "summary": "success",
    "uid": {{생성한 챗uid}},
    "uid_str": "{{생성한 챗uid}}",
    "url": "{{문서 url}}"
}
```

{% endtab %}

{% tab title="400: Bad Request Insufficient PDF 내용" %}

```json
{
    "detail": {
        "code": 70004,
        "msg": "document_insufficient_data"
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 업로드 실패" %}

```json
{
    "detail": {
        "code": 70004,
        "msg": "failed_to_upload"
    }
}
```

{% endtab %}
{% endtabs %}

## 문서 요약 내용 생성

업로드한 문서가 `conversation_uid` 가져와서 요약내용을 생성할 수 있습니다.\
&#x20;\
\&#xNAN;*`conversation_uid`없을 경우 최근 업로드한 문서를 사용합니다.* &#x20;

## 업로드한 문서의 요약내용 생성

<mark style="color:blue;">`GET`</mark> `https://api.deepsearch.com/note/v1/pdf/init_summary`

업로드한 문서의 요약내용 생성

#### Request Body

| Name              | Type    | Description           |
| ----------------- | ------- | --------------------- |
| conversation\_uid | String  | 업로드한 PDF의 챗UID        |
| category          | String  | 문서 카테고리               |
| stream            | boolean | client에서 결과 stream 여부 |

{% tabs %}
{% tab title="200: OK 성공" %}

```json
{
    "index": 0,
    "message": {
        "role": "assistant",
        "content": "{{요약 내용}}"
    },
    "finish_reason": "stop"
}
```

{% endtab %}

{% tab title="200: OK stream = True 성공" %}
GPT처럼 [Server Sent Event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)으로 데이터 받기.

```
data: 

data: 삼

data: 성

data: 전

data: 자

data: 의

data:  매
........
........
```

{% endtab %}

{% tab title="404: Not Found 문서 없음 애러" %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "document_not_found"
    }
}
```

{% endtab %}
{% endtabs %}

## 업로드한 문서의 요약내용 생성

<mark style="color:green;">`POST`</mark> `https://api.deepsearch.com/note/v1/pdf/init_summary`

업로드한 문서의 요약내용 생성

#### Request Body

| Name              | Type    | Description           |
| ----------------- | ------- | --------------------- |
| conversation\_uid | String  | 업로드한 PDF의 챗UID        |
| category          | String  | 문서 카테고리               |
| stream            | boolean | client에서 결과 stream 여부 |

{% tabs %}
{% tab title="200: OK 성공" %}

```json
{
    "index": 0,
    "message": {
        "role": "assistant",
        "content": "{{요약 내용}}"
    },
    "finish_reason": "stop"
}
```

{% endtab %}

{% tab title="200: OK stream = True 성공" %}
GPT처럼 [Server Sent Event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)으로 데이터 받기.

```
data: 

data: 삼

data: 성

data: 전

data: 자

data: 의

data:  매
........
........
```

{% endtab %}

{% tab title="404: Not Found 문서 없음 애러" %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "document_not_found"
    }
}
```

{% endtab %}
{% endtabs %}

## 문서 질문 생성

업로드한 문서가 `conversation_uid` 가져와서 질문을 생성할 수 있습니다.\
\
\&#xNAN;*`conversation_uid`없을 경우 최근 업로드한 문서를 사용합니다.* &#x20;

## 업로드한 문서의 질문 생성

<mark style="color:blue;">`GET`</mark> `https://api.deepsearch.com/note/v1/pdf/init_question`

업로드한 문서의 질문 생성

#### Request Body

| Name              | Type    | Description           |
| ----------------- | ------- | --------------------- |
| conversation\_uid | String  | 업로드한 PDF의 챗UID        |
| category          | String  | 문서 카테고리               |
| stream            | boolean | client에서 결과 stream 여부 |

{% tabs %}
{% tab title="200: OK 성공" %}

```json
{
    "index": 0,
    "message": {
        "role": "assistant",
        "content": "{{질문 내용}}"
    },
    "finish_reason": "stop"
}
```

{% endtab %}

{% tab title="200: OK stream = True 성공" %}
GPT처럼 [Server Sent Event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)으로 데이터 받기.

```
data: 

data: 삼

data: 성

data: 전

data: 자

data: 의

data:  매
........
........
```

{% endtab %}

{% tab title="404: Not Found 문서 없음 애러" %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "document_not_found"
    }
}
```

{% endtab %}
{% endtabs %}

## 업로드한 문서의 질문 생성

<mark style="color:green;">`POST`</mark> `https://api.deepsearch.com/note/v1/pdf/init_question`

업로드한 문서의 질문 생성

#### Request Body

| Name              | Type    | Description           |
| ----------------- | ------- | --------------------- |
| conversation\_uid | String  | 업로드한 PDF의 챗UID        |
| category          | String  | 문서 카테고리               |
| stream            | boolean | client에서 결과 stream 여부 |

{% tabs %}
{% tab title="200: OK 성공" %}

```json
{
    "index": 0,
    "message": {
        "role": "assistant",
        "content": "{{질문 내용}}"
    },
    "finish_reason": "stop"
}
```

{% endtab %}

{% tab title="200: OK stream = True 성공" %}
GPT처럼 [Server Sent Event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)으로 데이터 받기.

```
data: 

data: 삼

data: 성

data: 전

data: 자

data: 의

data:  매
........
........
```

{% endtab %}

{% tab title="404: Not Found 문서 없음 애러" %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "document_not_found"
    }
}
```

{% endtab %}
{% endtabs %}

## 문서 QA하기

업로드한 문서가 `conversation_uid` 가져와서 문서에 대해 질의응답할 수 있습니다.\
\
\&#xNAN;*`conversation_uid`없을 경우 최근 업로드한 문서를 사용합니다.* &#x20;

## 업로드한 문서의 질의응답하기

<mark style="color:blue;">`GET`</mark> `https://api.deepsearch.com/note/v1/pdf/answer`

업로드한 문서의 질의응답하기

#### Request Body

| Name                                       | Type    | Description           |
| ------------------------------------------ | ------- | --------------------- |
| conversation\_uid                          | String  | 업로드한 PDF의 챗UID        |
| category                                   | String  | 문서 카테고리               |
| stream                                     | boolean | client에서 결과 stream 여부 |
| question<mark style="color:red;">\*</mark> | String  | 사용자 질문                |
| history                                    | List    | 챗 히스토리                |

{% tabs %}
{% tab title="200: OK 성공" %}

```json
{
    "index": 0,
    "message": {
        "role": "assistant",
        "content": "{{답변}}"
    },
    "finish_reason": "stop"
}
```

{% endtab %}

{% tab title="200: OK stream = True 성공" %}
GPT처럼 [Server Sent Event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)으로 데이터 받기.

```
data: 

data: 삼

data: 성

data: 전

data: 자

data: 의

data:  매
........
........
```

{% endtab %}

{% tab title="404: Not Found 문서 없음 애러" %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "document_not_found"
    }
}
```

{% endtab %}

{% tab title="404: Not Found 답변 없음" %}

```
{
    "detail": {
        "code": 70001,
        "msg": "no_answer_found"
    }
}
```

{% endtab %}
{% endtabs %}

## 업로드한 문서의 질의응답하기

<mark style="color:green;">`POST`</mark> `https://api.deepsearch.com/note/v1/pdf/answer`

업로드한 문서의 질의응답하기

#### Request Body

| Name                                       | Type    | Description           |
| ------------------------------------------ | ------- | --------------------- |
| conversation\_uid                          | String  | 업로드한 PDF의 챗UID        |
| category                                   | String  | 문서 카테고리               |
| stream                                     | boolean | client에서 결과 stream 여부 |
| question<mark style="color:red;">\*</mark> | String  | 사용자 질문                |
| history                                    | List    | 챗 히스토리                |

{% tabs %}
{% tab title="200: OK 성공" %}

```json
{
    "index": 0,
    "message": {
        "role": "assistant",
        "content": "{{답변}}"
    },
    "finish_reason": "stop"
}
```

{% endtab %}

{% tab title="200: OK stream = True 성공" %}
GPT처럼 [Server Sent Event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)으로 데이터 받기.

```
data: 

data: 삼

data: 성

data: 전

data: 자

data: 의

data:  매
........
........
```

{% endtab %}

{% tab title="404: Not Found 문서 없음 애러" %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "document_not_found"
    }
}
```

{% endtab %}

{% tab title="404: Not Found 답변 없음 " %}

```json
{
    "detail": {
        "code": 70001,
        "msg": "no_answer_found"
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.deepsearch.com/dp/api/chat/qa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
