From af5431d6dbff325c283443e67d185335a783ad0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 10 Aug 2026 18:22:16 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20LLM=20enrichment=20(GPT-120)=20?= =?UTF-8?q?=E2=80=94=20137=20files,=201=20failure=20(postgres=5Fparams=5Fc?= =?UTF-8?q?reate=20timeout,=20copied=20original)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TOOLS/scripts/05_generate_docs_llm.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/TOOLS/scripts/05_generate_docs_llm.py b/TOOLS/scripts/05_generate_docs_llm.py index a4523c1..39721f3 100644 --- a/TOOLS/scripts/05_generate_docs_llm.py +++ b/TOOLS/scripts/05_generate_docs_llm.py @@ -7,7 +7,7 @@ LLM-улучшатель документации Nubes Terraform Provider. Использование: python3 05_generate_docs_llm.py generated/test/docs [--out generated/test/docs_llm] """ -import json, os, re, shutil, sys, time +import json, os, re, shutil, sys, time, socket from pathlib import Path from urllib.request import Request, urlopen @@ -129,9 +129,10 @@ def call_llm(prompt: str) -> str: "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", }) - for attempt in range(3): + for attempt in range(2): try: - with urlopen(req, timeout=120) as resp: + socket.setdefaulttimeout(90) + with urlopen(req, timeout=90) as resp: result = json.loads(resp.read()) content = result["choices"][0]["message"]["content"].strip() if content.startswith("```"): @@ -140,9 +141,9 @@ def call_llm(prompt: str) -> str: content = "\n".join(lines[1:-1]) return content except Exception as e: - print(f" retry {attempt+1}/3: {e}", file=sys.stderr) - time.sleep(5) - raise RuntimeError("LLM failed after 3 retries") + print(f" retry {attempt+1}/2: {e}", file=sys.stderr) + time.sleep(3) + raise RuntimeError("LLM failed after 2 retries") def extract_man(text: str) -> str: @@ -237,6 +238,13 @@ def main(): continue total += 1 + dest = out_dir / f.name + + # Skip already processed files + if dest.exists() and dest.stat().st_size > 100: + print(f" {f.name}... SKIP (already done)", flush=True) + continue + print(f" {f.name}...", end=" ", flush=True) content = f.read_text()