61 lines
1.9 KiB
Python
Executable File
61 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""v3.40.11: Fix _RE_IMO/_RE_MMSI undefined, fix cerebras model, version bump."""
|
|
|
|
fixes = 0
|
|
|
|
# ============================================================
|
|
# FIX 1: Add _RE_IMO and _RE_MMSI regex before _extract_entities
|
|
# ============================================================
|
|
PATH = '/opt/app/seafare_agent.py'
|
|
c = open(PATH).read()
|
|
|
|
old = """def _extract_entities(msg: str) -> dict:
|
|
\"\"\"Extract maritime entities from message text."""
|
|
|
|
new = """# Regex for IMO/MMSI extraction in smart parse
|
|
_RE_IMO = re.compile(r'(?:IMO[:\s#-]*)?(\d{7})(?!\d)')
|
|
_RE_MMSI = re.compile(r'(?:MMSI[:\s#-]*)?(\d{9})(?!\d)')
|
|
|
|
def _extract_entities(msg: str) -> dict:
|
|
\"\"\"Extract maritime entities from message text."""
|
|
|
|
if old in c:
|
|
c = c.replace(old, new, 1)
|
|
fixes += 1
|
|
print("FIX 1: Added _RE_IMO and _RE_MMSI regex definitions")
|
|
else:
|
|
print("FIX 1: marker not found")
|
|
|
|
open(PATH, 'w').write(c)
|
|
|
|
# ============================================================
|
|
# FIX 2: Fix cerebras model — use a model that actually exists
|
|
# ============================================================
|
|
PATH_CFG = '/opt/app/config.py'
|
|
c2 = open(PATH_CFG).read()
|
|
|
|
old = "CEREBRAS_MODEL = 'qwen-3-235b-a22b-instruct-2507'"
|
|
new = "CEREBRAS_MODEL = 'llama-3.3-70b'"
|
|
if old in c2:
|
|
c2 = c2.replace(old, new, 1)
|
|
fixes += 1
|
|
print("FIX 2: Cerebras model fixed → llama-3.3-70b")
|
|
else:
|
|
print("FIX 2: cerebras model marker not found")
|
|
|
|
# ============================================================
|
|
# FIX 3: Version bump
|
|
# ============================================================
|
|
old = "APP_VERSION = '3.40.10'"
|
|
new = "APP_VERSION = '3.40.11'"
|
|
if old in c2:
|
|
c2 = c2.replace(old, new, 1)
|
|
fixes += 1
|
|
print("FIX 3: Version → 3.40.11")
|
|
else:
|
|
print("FIX 3: version marker not found")
|
|
|
|
open(PATH_CFG, 'w').write(c2)
|
|
|
|
print(f"\nTotal fixes: {fixes}")
|