Fix GUI stale url issue

This commit is contained in:
dazedanon 2026-04-04 14:06:05 -05:00
parent 600ce598df
commit 6311929d05
3 changed files with 16 additions and 3 deletions

View file

@ -313,6 +313,7 @@ class ConfigTab(QWidget):
("OpenAI", "https://api.openai.com/v1"),
("Claude (Anthropic)", "https://api.anthropic.com/v1"),
("Gemini", "https://generativelanguage.googleapis.com/v1beta/openai/"),
("DeepSeek", "https://api.deepseek.com/v1"),
]
for _name, _url in _url_presets:
_action = api_url_menu.addAction(_name)

View file

@ -218,7 +218,7 @@ PATTERNS_355655 = {
"AddAddress": (r'AddAddress\(\d+,\s*\\?"(.+?)\\?"', False),
}
# Subset of PATTERNS_355655 keys that should be processed (empty = none).
ENABLED_PATTERNS_355655: set = {"BattleManager._logWindow.push('addText'"}
ENABLED_PATTERNS_355655: set = {"_subject="}
def handleMVMZ(filename, estimate):
@ -3278,7 +3278,7 @@ def searchCodes(page, pbar, jobList, filename):
elif "DW_" in jaString:
regex = r"DW_.*\s\d+\s(.+)"
elif "CommonPopup" in jaString:
regex = r"CommonPopup\sadd\stext:(.*?)[\\]+}"
regex = r"CommonPopup\sadd\stext:(.+?)(?=\s+count:|\s*$)"
elif "AddCustomChoice" in jaString:
regex = r"AddCustomChoice\s\d+\s(.+)\s\d"
else:

View file

@ -877,7 +877,19 @@ def translateText(system, user, history, penalty, formatType, model, numLines=No
raise ValueError(f"Message {i} has empty content: {message}")
# --- API Call Logic ---
api_provider = os.getenv("API_PROVIDER", "openai").lower()
# Re-apply env vars here so that GUI config changes (which update os.environ
# but cannot re-run module-level code) are always reflected at call time.
_live_api = os.getenv("api", "").strip()
_live_key = os.getenv("key", "").strip()
_live_provider = os.getenv("API_PROVIDER", "openai").lower()
if _live_provider == "gemini":
openai.base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
elif _live_api:
openai.base_url = _live_api
if _live_key:
openai.api_key = _live_key
api_provider = _live_provider
# Omit response_format for plain text — some providers reject {"type": "text"}.
params = {