diff --git a/batch.py b/batch.py index fc54c68..7229ba9 100644 --- a/batch.py +++ b/batch.py @@ -144,19 +144,24 @@ async def analyze_structure(sample_files: list[str], target_file: str, task_desc }}""" proxy = os.environ.get("HTTPS_PROXY") or os.environ.get("HTTP_PROXY") - async with httpx.AsyncClient(timeout=120, proxy=proxy) as client: + async with httpx.AsyncClient(timeout=300, proxy=proxy) as client: resp = await client.post( f"{ZAI_BASE_URL}/chat/completions", headers={"Authorization": f"Bearer {ZAI_API_KEY}"}, json={ "model": ZAI_MODEL, - "messages": [{"role": "user", "content": prompt}], + "messages": [ + {"role": "system", "content": "Ты генерируешь ТОЛЬКО валидный JSON. Никакого текста вне JSON."}, + {"role": "user", "content": prompt}, + ], "temperature": 0.1, "max_tokens": 4000, + "response_format": {"type": "json_object"}, }, ) resp.raise_for_status() - content = resp.json()["choices"][0]["message"]["content"] + msg = resp.json()["choices"][0]["message"] + content = msg.get("content") or msg.get("reasoning_content") or "" # Parse JSON from response try: