mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-18 07:42:09 +00:00
var fx
This commit is contained in:
+5
-1
@@ -7,6 +7,7 @@ import re
|
||||
import shlex
|
||||
import tempfile
|
||||
import zipfile
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
@@ -32,6 +33,7 @@ async def run_latex_two_passes(
|
||||
tex_filename: str, workdir: Path, tex_engine: str, timeout_sec: int, logger=None
|
||||
) -> Tuple[bool, str, Path]:
|
||||
cmd = f"{tex_engine} -interaction=nonstopmode -halt-on-error -file-line-error -no-shell-escape {shlex.quote(tex_filename)}"
|
||||
logger = logging.getLogger(logger) if logger else None
|
||||
if logger:
|
||||
logger.debug("LaTeX cmd: %s (cwd=%s)", cmd, workdir)
|
||||
|
||||
@@ -151,12 +153,14 @@ async def compile_zip_to_zip(
|
||||
|
||||
|
||||
async def ask_openai_diagnosis(
|
||||
log_text: str, tex_excerpt: str, api_key: str, model: str, logger=None
|
||||
log_text: str, tex_excerpt: str, model: str, logger:str = None
|
||||
) -> str:
|
||||
logger = logging.getLogger(logger) if logger else None
|
||||
sys = (
|
||||
"You are a LaTeX build diagnostician. Analyze pdflatex log and return:\n"
|
||||
"1) Root causes (bullets)\n2) Minimal working fix (code block)\n3) Alternative fix"
|
||||
)
|
||||
logger.debug("LaTeX DIAG (%s)\n%s", model, log_text[-9000:])
|
||||
usr = f"---LOG---\n{log_text[-9000:]}\n---END LOG---"
|
||||
if tex_excerpt:
|
||||
usr += f"\n---TEX EXCERPT---\n{tex_excerpt[:4000]}\n---END EXCERPT---"
|
||||
|
||||
Reference in New Issue
Block a user