Enhance: Address/VAT Sync & Infrastructure Hardening [30e88f42]

- Implemented Address (City) and VAT (OrgNumber) sync back to SuperOffice.
- Hardened Infrastructure: Removed Pydantic dependency in config for better Docker compatibility.
- Improved SuperOffice Client error logging and handled empty SO_ENVIRONMENT variables.
- Updated Matrix Generator: Switched to gemini-2.0-flash, added industry filtering, and robust JSON parsing.
- Updated Documentation with session findings and troubleshooting steps.
This commit is contained in:
2026-02-21 21:26:57 +00:00
parent 7d038765cc
commit 72c2a53afc
8 changed files with 169 additions and 51 deletions

View File

@@ -12,7 +12,7 @@ from backend.database import SessionLocal, Industry, Persona, MarketingMatrix
from backend.config import settings
# --- Configuration ---
MODEL_NAME = "gemini-1.5-pro-latest" # High quality copy
MODEL_NAME = "gemini-2.0-flash" # High quality copy
def generate_prompt(industry: Industry, persona: Persona) -> str:
"""
@@ -104,15 +104,25 @@ def real_gemini_call(prompt: str):
elif text.startswith("```"):
text = text[3:-3].strip()
return json.loads(text)
parsed_json = json.loads(text)
if isinstance(parsed_json, list):
if len(parsed_json) > 0:
return parsed_json[0]
else:
raise ValueError("Empty list returned from API")
return parsed_json
except Exception as e:
print(f"JSON Parse Error: {e}. Raw Response: {response.text}")
raise
def run_matrix_generation(dry_run: bool = True, force: bool = False):
def run_matrix_generation(dry_run: bool = True, force: bool = False, specific_industry: str = None):
db = SessionLocal()
try:
industries = db.query(Industry).all()
query = db.query(Industry)
if specific_industry:
query = query.filter(Industry.name == specific_industry)
industries = query.all()
personas = db.query(Persona).all()
print(f"Found {len(industries)} Industries and {len(personas)} Personas.")
@@ -182,6 +192,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--live", action="store_true", help="Actually call Gemini and write to DB")
parser.add_argument("--force", action="store_true", help="Overwrite existing matrix entries")
parser.add_argument("--industry", type=str, help="Specific industry name to process")
args = parser.parse_args()
run_matrix_generation(dry_run=not args.live, force=args.force)
run_matrix_generation(dry_run=not args.live, force=args.force, specific_industry=args.industry)