Files
llm-gateway-sub-backup/workspace/static/html/general_guide.html
2025-08-11 18:56:38 +09:00

177 lines
8.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>🧾 일반 추론 API 가이드</title>
<style>
body { font-family: 'Arial', sans-serif; margin: 40px; line-height: 1.6; }
h1, h2 { color: #2c3e50; }
code, pre { background: #f4f4f4; padding: 10px; display: block; white-space: pre-wrap; border-left: 4px solid #3498db; }
.warn { color: #c0392b; font-weight: bold; }
</style>
</head>
<body>
<h1>🧾 일반 추론 API 가이드</h1>
<p>
🔹 <strong>/general</strong> 계열 API를 활용하여 문서 기반 질문-응답 요약을 수행하는 방법을 안내합니다.<br>
🔹 공문 외에 다양한 도메인에 적용 가능하며, 사용자는 <strong>URL(Markdwon)</strong> 또는 <strong>JSON</strong> 구조로 답변을 받습니다.
</p>
<h3>📌 사용 가능한 API 종류</h3>
<p>
🔹 <strong>/general/inner</strong>: 내부 모델을 사용하여 일반 요약 수행<br>
🔹 <strong>/general/outer</strong>: 외부 모델(GPT, Claude, Gemini 등)을 사용하여 요약 수행
</p>
<hr>
<h2>✅ 프롬프트 작성 예시</h2>
<p>
🔹 <strong>프롬프트 파일은 반드시 업로드</strong>해야 합니다.<br>
🔹 [예시] 질문은 다음과 같이 구성할 수 있습니다:
</p>
<code>문서 분석
[Q1] 이 문서의 주요 내용을 요약해주세요.
[Q2] 발신자와 수신자 정보를 정리해주세요.
[Q3] 문서에서 요청하는 주요 조치를 요약해주세요.
[Q4] 날짜, 장소, 인명 등 주요 엔티티를 추출해주세요.
[Q5] 이 문서의 목적이나 배경을 기술해주세요.
</code>
<hr>
<h2>✅ Schema JSON 작성 예시</h2>
<p>
🔹 <strong>schema_file은 선택사항</strong>이며, JSON 형식으로 답변 받기 위해선 작성이 필요합니다.<br>
🔹 추출이 필요한 항목과 항목의 답변을 정의할 때 사용합니다.<br>
🔹 특수 항목은 <strong>enum</strong> 또는 <strong>type</strong> 값을 값정할 수 있습니다.
</p>
<pre>
{
"title": "DocumentSummary",
"type": "object",
"properties": {
"공문번호": { "type": "string" },
"공문일자": { "type": "string" },
"수신체": { "type": "string" },
"수신자": { "type": "string" },
"수신자_약자": { "type": "string" },
"발신체": { "type": "string" },
"발신자": { "type": "string" },
"발신자_약자": { "type": "string" },
"공문제목": { "type": "string" },
"공문제목요약": { "type": "string" },
"공문내용요약": { "type": "string" },
"공문간연계": { "type": "string" },
"공문종류": {
"type": "string",
"enum": ["행정/일반", "기술/성과물", "회의/기타"]
},
"공문유형": {
"type": "string",
"enum": ["보고", "요청", "지시", "회신", "계약"]
},
"첨부문서제목": { "type": "string" },
"첨부문서수": { "type": "integer" }
},
"required": [
"공문번호", "공문일자", "수신체", "수신자", "수신자_약자",
"발신체", "발신자", "발신자_약자", "공문제목", "공문제목요약",
"공문내용요약", "공문종류", "공문유형", "첨부문서제목", "첨부문서수"
]
}</pre>
<h3>📌 주요 키·속성 설명</h3>
<p>🔹 위 JSON 예시는 <strong>Schema 구조</strong>를 정의하는 방식으로 작성되어 있으며, 각 키의 의미는 다음과 같습니다:</p>
<ul>
<li><strong>title</strong>: 스키마의 이름 또는 제목을 정의합니다. 주로 문서나 데이터 객체의 이름을 지정하는 데 사용됩니다.<br>
[예시]: <strong>"title": "DocumentSummary"</strong> → 이 JSON은 DocumentSummary라는 이름의 구조입니다.</li>
<br>
<li><strong>type</strong>: 이 JSON 구조 자체가 어떤 형태의 데이터인지 정의합니다.<br>
[예시]: <strong>"type": "object"</strong> → 이 스키마는 key-value 쌍으로 이루어진 객체(object)입니다.</li>
<br>
<li><strong>properties</strong>: 객체 안에 포함된 각 필드(속성)를 정의하는 부분입니다.<br>
이 안에는 각각의 필드 이름(key)과 해당 값의 <strong>type</strong><strong>enum</strong> 등 상세 정보가 포함됩니다.<br>
[예시]: <strong>"공문번호": { "type": "string" }</strong> → 공문번호는 문자열 타입이어야 함을 의미합니다.</li>
<br>
<ul>
<li><strong>type</strong>: 해당 값의 데이터 유형을 지정합니다. 주요 유형은 다음과 같습니다:
<ul>
<li><strong>string</strong>: 문자열 (예: "서울특별시")</li>
<li><strong>integer</strong>: 정수 (예: 3, 25)</li>
<li><strong>boolean</strong>: 참/거짓 값 (예: true, false)</li>
</ul>
</li>
<li><strong>enum</strong>: 해당 필드가 가질 수 있는 값을 목록으로 제한합니다. 지정된 값 외에는 허용되지 않습니다.
<br>[예시]: <strong>"공문종류": { "type": "string", "enum": ["행정/일반", "기술/성과물", "회의/기타"] }</strong>
</li>
</ul>
<br>
<li><strong>required</strong>: 필수로 입력되어야 하는 항목들의 리스트입니다.<br>
이 배열에 나열된 필드가 누락될 경우, JSON이 유효하지 않은 것으로 간주됩니다.<br>
[예시]: <strong>"required": ["공문번호", "공문일자", ...]</strong> → 이 필드들은 반드시 포함되어야 합니다.</li>
</ul>
<p class="warn">Tip. schemna json을 사용하는 경우, <strong>프롬프트의 각 항목에 대한 지시문(description)을 각분으로 설정</strong>해주면 더 좋습니다.</p>
<code> 1. 공문번호: 문서 번호를 기입하세요. (예시: Ref. No. SYJV-250031)
2. 공문일자: 공문 발행일을 작성하세요. (예시: Mar / 28 / 2025)
3. 수신처: 수신 기관이나 부서명을 작성하세요. (예시: Department of Public Works and Highways)
...
16. 첨부문서수: 첨부문서제목을 바탕으로 문서의 개수를 작성하세요.
</code>
</body>
</html>
<hr>
<h2>✅ 사용 절차 안내</h2>
<p>
🔹 해당 API에 업로드 가능한 파일은 3가지로 구성됩니다:
</p>
<img src="static/image/FastAPI_general.png" alt="FastAPI general 입력 화면 예시" width="600" style="border: 2px solid #ccc; border-radius: 4px;"/>
<h3>📌 API 첨부 파일 설명</h3>
<ul>
<li><strong>input_file</strong>: <span class="warn">(필수)</span> PDF, 이미지 등 추론 대상 파일을 업로드합니다.</li>
<li><strong>prompt_file</strong>: <span class="warn">(필수)</span> 질문이 포함된 질문이 포함된 프롬프트 텍스트(.txt)를 업로드합니다.</li>
<li><strong>schema_file</strong>: <span class="warn">(선택)</span> 응답 구조를 정의한 스키마 파일(.json)을 업로드합니다.</li>
</ul>
<hr>
<h2>1⃣ Markdown 형식 응답 예시(schema file 미업로드)</h2>
<p>
🔹 모델은 질문에 대해 <strong>줄글 형식의 응답을 생성</strong>하며, 응답 JSON에는 다음 필드가 포함됩니다:
</p>
<img src="static/image/FastAPI_general_response.png" alt="FastAPI general 결과 화면 예시" width="600" style="border: 2px solid #ccc; border-radius: 4px;"/>
<h3>📌 주요 답변 키 설명</h3>
<ul>
<li><strong>generated</strong>: 마크다운 형식의 응답 텍스트</li>
<li><strong>summary_html</strong>: 마크다운을 HTML로 변환하여 저장한 URL</li>
🔗<a href="http://172.16.10.176:8888/view/generated_html/Contract_for_Main_Office.html" target="_blank">
http://172.16.10.176:8888/view/generated_html/Contract_for_Main_Office.html
</a>
</ul>
<img src="static/image/FastAPI_general_result.png" alt="FastAPI general 결과 화면 예시" width="600" style="border: 2px solid #ccc; border-radius: 4px;"/>
<hr>
<h2>2⃣ 구조화 JSON 형식 응답 예시(schema file 업로드)</h2>
<p>
🔹 /general API에 <strong>schema_file</strong>을 함께 업로드한 경우, 모델은 지정된 JSON Schema에 따라 항목별 응답을 생성합니다.
</p>
<img src="static/image/FastAPI_general_JSONresult.png" alt="FastAPI structured 응답 예시" width="600" style="border: 2px solid #ccc; border-radius: 4px;"/>
<h3>📌 주요 답변 키 설명</h3>
<ul>
<li><strong>generated</strong>: JSON 구조의 응답 데이터</li>
<li><strong>processed</strong>: 구조화된 응답이므로 별도의 후처리는 생략되며, 안내 메시지만 포함됩니다.</li>
</ul>
<p class="warn">※ Claude 모델은 <strong>영문 필드명만 허용</strong>합니다.</p>
</body>
</html>