fix: API key path + YAML error handling in decision extractor
Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70>
This commit is contained in:
parent
a292ab75c2
commit
e1934b30ae
1 changed files with 7 additions and 4 deletions
|
|
@ -39,8 +39,8 @@ def call_llm(prompt: str, max_tokens: int = 4096) -> str | None:
|
||||||
"""Call OpenRouter API."""
|
"""Call OpenRouter API."""
|
||||||
api_key = os.environ.get("OPENROUTER_API_KEY", "")
|
api_key = os.environ.get("OPENROUTER_API_KEY", "")
|
||||||
if not api_key:
|
if not api_key:
|
||||||
# Try reading from file
|
# Try reading from file (same location as openrouter-extract-v2.py)
|
||||||
key_file = Path("/opt/teleo-eval/.openrouter-key")
|
key_file = Path("/opt/teleo-eval/secrets/openrouter-key")
|
||||||
if key_file.exists():
|
if key_file.exists():
|
||||||
api_key = key_file.read_text().strip()
|
api_key = key_file.read_text().strip()
|
||||||
if not api_key:
|
if not api_key:
|
||||||
|
|
@ -99,7 +99,7 @@ def parse_frontmatter(path: Path) -> tuple[dict | None, str]:
|
||||||
return None, text
|
return None, text
|
||||||
body = text[end + 4:].strip()
|
body = text[end + 4:].strip()
|
||||||
return fm, body
|
return fm, body
|
||||||
except yaml.YAMLError:
|
except Exception:
|
||||||
return None, text
|
return None, text
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,7 +109,10 @@ def find_proposal_sources() -> list[Path]:
|
||||||
"""Find all unprocessed proposal sources in archive."""
|
"""Find all unprocessed proposal sources in archive."""
|
||||||
sources = []
|
sources = []
|
||||||
for md_file in sorted(ARCHIVE_DIR.rglob("*.md")):
|
for md_file in sorted(ARCHIVE_DIR.rglob("*.md")):
|
||||||
fm, _ = parse_frontmatter(md_file)
|
try:
|
||||||
|
fm, _ = parse_frontmatter(md_file)
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
if not fm:
|
if not fm:
|
||||||
continue
|
continue
|
||||||
if fm.get("event_type") == "proposal" and fm.get("status") in ("unprocessed", None):
|
if fm.get("event_type") == "proposal" and fm.get("status") in ("unprocessed", None):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue