forked from PG219/PharmaMind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (20 loc) · 700 Bytes
/
utils.py
File metadata and controls
25 lines (20 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# utils.py
import os
import json
from datetime import datetime
from openai import OpenAI
MODEL_NAME = os.getenv("PHARMAMIND_MODEL", "tngtech/deepseek-r1t2-chimera:free")
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
if not OPENROUTER_API_KEY:
raise EnvironmentError("OPENROUTER_API_KEY not set. Export it before running.")
def get_openrouter_client():
return OpenAI(base_url="https://openrouter.ai/api/v1", api_key=OPENROUTER_API_KEY)
def now_iso():
return datetime.utcnow().isoformat() + "Z"
def safe_get(d, *keys, default=None):
cur = d
for k in keys:
if not isinstance(cur, dict):
return default
cur = cur.get(k, default)
return cur