From 7656de0cc4059ddd446020ee81ee59871b17f497 Mon Sep 17 00:00:00 2001 From: "LASTA_DEV01\\lasta" Date: Fri, 8 May 2026 17:44:11 +0900 Subject: [PATCH] =?UTF-8?q?[=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crawler_platform.db-journal | Bin 8720 -> 0 bytes .../app/core/extractor/ai_provider.py | 50 ++++++++++++++++++ 2 files changed, 50 insertions(+) delete mode 100644 crawler_platform.db-journal diff --git a/crawler_platform.db-journal b/crawler_platform.db-journal deleted file mode 100644 index 8a9558b76cd425bfe290982506a2144ee2762d33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8720 zcmeHNPm3c(6z`cu+!b{cyex|ldM|s}37uqmlF4PrfO}9@2i==4O{M!KQ%-kRZ&h_> zL&!%Eudd*?5d0K-_TXLc;%D%^s`Q_PthgWxN)-cL^;0b@ID8M$9o+uZ!#~#?1C9a5fMdWh;23ZWye0$R4-Rg7;k}k>VDxUKWPc%1tS2St=c+uz(Z^3%X|^p`*M@NtV1!Q?#%& z6*rJX1=ClC3F4(-Qh}shm_rVjB`r7u9bZ|igl8ovZ9qz^JSx6F;$m3_MeENDtH_{HWk`3T;Ne}4I52>g}4S)DT6AxX44cN3E7B5%UJ6L zCaUn1r%XN(l(iCRaS3Rc%PiY<|`-W^oHBuc0e zrG5UEDp_}%gG!{Vr=cUO6$?E(+_dxyoh?=xs|MWNrkAqPs7>>iUad^`0h5g~#sO=ez`-5?K+C3W#hGFpF zaB11R`>jm y7u0?{di@YR{BoZiV2HuTn-JAaLhI7EGM)cvp?vhJI47f^xAz_(q&W2dAAbQzw&j8V diff --git a/crawler_platform/app/core/extractor/ai_provider.py b/crawler_platform/app/core/extractor/ai_provider.py index 24d497d..35f6faf 100644 --- a/crawler_platform/app/core/extractor/ai_provider.py +++ b/crawler_platform/app/core/extractor/ai_provider.py @@ -149,6 +149,7 @@ class LLMJsonExtractor(AIExtractor): {"role": "user", "content": prompt}, ], "temperature": 0, + "response_format": extraction_response_format(), }, timeout=self.timeout_seconds, ) @@ -266,6 +267,55 @@ Page text: """.strip() +def extraction_response_format() -> dict[str, Any]: + return { + "type": "json_schema", + "json_schema": { + "name": "ontology_extraction", + "schema": { + "type": "object", + "properties": { + "entities": { + "type": "array", + "items": { + "type": "object", + "properties": { + "entity_type": {"type": "string"}, + "type": {"type": "string"}, + "name": {"type": "string"}, + "attributes": {"type": "object"}, + "confidence": {"type": "number"}, + "evidence_text": {"type": "string"}, + }, + "required": ["name"], + }, + }, + "claims": { + "type": "array", + "items": { + "type": "object", + "properties": { + "subject_name": {"type": "string"}, + "subject_type": {"type": "string"}, + "predicate": {"type": "string"}, + "object_name": {"type": ["string", "null"]}, + "object_type": {"type": ["string", "null"]}, + "object_value": {}, + "evidence_text": {"type": ["string", "null"]}, + "evidence_summary": {"type": ["string", "null"]}, + "confidence": {"type": "number"}, + "confidence_reason": {"type": ["string", "null"]}, + }, + "required": ["subject_name", "subject_type", "predicate"], + }, + }, + }, + "required": ["entities", "claims"], + }, + }, + } + + def parse_json_content(content: str, retry=None) -> dict[str, Any]: try: return json.loads(content)