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:
@@ -101,6 +101,11 @@ class ProvisioningResponse(BaseModel):
|
||||
opener: Optional[str] = None # Primary opener (Infrastructure/Cleaning)
|
||||
opener_secondary: Optional[str] = None # Secondary opener (Service/Logistics)
|
||||
texts: Dict[str, Optional[str]] = {}
|
||||
|
||||
# Enrichment Data for Write-Back
|
||||
address_city: Optional[str] = None
|
||||
address_country: Optional[str] = None
|
||||
vat_id: Optional[str] = None
|
||||
|
||||
class IndustryDetails(BaseModel):
|
||||
pains: Optional[str] = None
|
||||
@@ -346,7 +351,11 @@ def provision_superoffice_contact(
|
||||
role_name=role_name,
|
||||
opener=company.ai_opener,
|
||||
opener_secondary=company.ai_opener_secondary,
|
||||
texts=texts
|
||||
texts=texts,
|
||||
address_city=company.city,
|
||||
address_country=company.country,
|
||||
# TODO: Add VAT field to Company model if not present, for now using crm_vat if available
|
||||
vat_id=company.crm_vat
|
||||
)
|
||||
|
||||
@app.get("/api/companies")
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user