> ## Documentation Index
> Fetch the complete documentation index at: https://docs.factagora.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ask & verify

> 컬렉션 안에서만 근거를 찾아 답하고, 기존 Q&A를 검증합니다.

Collections는 여러 URL을 하나의 통합 지식 그래프(TKG)에 수집해 **브랜드별 프라이빗 코퍼스**를 구축합니다.

**개인 액세스 토큰(Personal Access Token)이 필요합니다.** 마스터 키는 사용할 수 없습니다.

## POST /api/v1/collections/{id}/answer

Collection의 지식 그래프만을 근거로 질문에 답변합니다. pgvector 시맨틱 검색으로 관련 내용을 먼저 추린 후 답변을 생성합니다.

지식 그래프에 충분한 정보가 없으면 `grounded: false`를 반환해 환각을 방지합니다.

### Request Body

<ParamField body="question" type="string" required>
  답변할 질문.
</ParamField>

<ParamField body="language" type="string" default="English">
  답변 언어. 예: `"Korean"`, `"Japanese"`
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.factagora.com/api/v1/collections/5966a861-6952-482a-a9d0-041ad5d2a667/answer" \
    -H "Authorization: Bearer fa_your_personal_token" \
    -H "Content-Type: application/json" \
    -d '{"question": "IONIQ 6의 주행 가능 거리는?", "language": "Korean"}'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "question": "IONIQ 6의 주행 가능 거리는?",
    "answer": "IONIQ 6는 최대 338마일(약 544km)의 주행 가능 거리를 제공합니다.",
    "grounded": true,
    "sources": [
      {
        "url": "https://www.hyundai.com/uk/en/models/ioniq6.html",
        "title": "IONIQ 6 | Hyundai UK"
      }
    ],
    "meta": {
      "executionTimeMs": 1285
    }
  }
  ```
</ResponseExample>

***

## POST /api/v1/collections/{id}/qa-verify

기존 Q\&A 쌍을 Collection 지식 그래프와 비교해 검증합니다. 각 쌍에 대해 세 가지 판정 중 하나를 반환합니다.

| 판정            | 의미                                           |
| ------------- | -------------------------------------------- |
| `correct`     | 답변이 지식 그래프의 내용과 일치함                          |
| `incorrect`   | 답변이 지식 그래프와 모순되며, `correction` 필드에 올바른 답변 제공 |
| `unsupported` | Collection에 검증에 충분한 정보가 없음                   |

### Request Body

<ParamField body="qa_pairs" type="array" required>
  검증할 Q\&A 쌍 목록 (1–50개).

  <Expandable title="qa_pairs 필드">
    <ParamField body="question" type="string" required>질문</ParamField>
    <ParamField body="answer" type="string" required>검증할 답변</ParamField>
  </Expandable>
</ParamField>

<ParamField body="language" type="string" default="English">
  판정 요약 및 수정 답변 언어.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.factagora.com/api/v1/collections/5966a861-6952-482a-a9d0-041ad5d2a667/qa-verify" \
    -H "Authorization: Bearer fa_your_personal_token" \
    -H "Content-Type: application/json" \
    -d '{
      "qa_pairs": [
        {
          "question": "IONIQ 6 충전 시간은?",
          "answer": "IONIQ 6는 10%에서 80%까지 18~36분 만에 충전됩니다."
        },
        {
          "question": "IONIQ 6는 가솔린 차량인가요?",
          "answer": "네, IONIQ 6는 가솔린 차량입니다."
        }
      ],
      "language": "Korean"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "results": [
      {
        "question": "IONIQ 6 충전 시간은?",
        "answer": "IONIQ 6는 10%에서 80%까지 18~36분 만에 충전됩니다.",
        "verdict": "correct",
        "confidence": 0.92,
        "correction": null,
        "summary": "지식 그래프에 따르면 IONIQ 6는 350kW 초고속 충전기로 10%에서 80%까지 18~36분 충전이 확인됩니다."
      },
      {
        "question": "IONIQ 6는 가솔린 차량인가요?",
        "answer": "네, IONIQ 6는 가솔린 차량입니다.",
        "verdict": "incorrect",
        "confidence": 0.95,
        "correction": "IONIQ 6는 완전한 전기차입니다. 가솔린 버전은 없습니다.",
        "summary": "지식 그래프는 IONIQ 6를 순수 전기차로만 설명하고 있습니다."
      }
    ],
    "meta": {
      "executionTimeMs": 2100
    }
  }
  ```
</ResponseExample>
