[31388f42] Fix Gemini API Key path resolution for Docker environment

This commit is contained in:
2026-03-02 09:31:10 +00:00
parent f5eaf02549
commit eada26bd5a
2 changed files with 36 additions and 17 deletions

View File

@@ -4,14 +4,21 @@ import requests
# Load API Key # Load API Key
def get_gemini_key(): def get_gemini_key():
try: candidates = [
# Try finding key in parent dir "gemini_api_key.txt", # Current dir
key_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'gemini_api_key.txt') "/app/gemini_api_key.txt", # Docker default
if os.path.exists(key_path): os.path.join(os.path.dirname(__file__), "gemini_api_key.txt"), # Script dir
with open(key_path, 'r') as f: os.path.join(os.path.dirname(os.path.dirname(__file__)), 'gemini_api_key.txt') # Parent dir
return f.read().strip() ]
except:
pass for path in candidates:
if os.path.exists(path):
try:
with open(path, 'r') as f:
return f.read().strip()
except:
pass
return os.getenv("GEMINI_API_KEY") return os.getenv("GEMINI_API_KEY")
def generate_email_draft(lead_data, company_data, booking_link="https://outlook.office365.com/owa/calendar/RoboplanetGmbH@robo-planet.de/bookings/"): def generate_email_draft(lead_data, company_data, booking_link="https://outlook.office365.com/owa/calendar/RoboplanetGmbH@robo-planet.de/bookings/"):
@@ -37,6 +44,7 @@ def generate_email_draft(lead_data, company_data, booking_link="https://outlook.
area = meta.get('area', 'Unbekannte Fläche') area = meta.get('area', 'Unbekannte Fläche')
purpose = meta.get('purpose', 'Reinigung') purpose = meta.get('purpose', 'Reinigung')
city = meta.get('city', '') city = meta.get('city', '')
role = meta.get('role', 'Unbekannt')
# Data from Company Explorer # Data from Company Explorer
ce_summary = company_data.get('summary', 'Keine Details verfügbar.') ce_summary = company_data.get('summary', 'Keine Details verfügbar.')
@@ -54,15 +62,18 @@ def generate_email_draft(lead_data, company_data, booking_link="https://outlook.
- Branche/Vertical: {ce_vertical} - Branche/Vertical: {ce_vertical}
- Web-Zusammenfassung: {ce_summary} - Web-Zusammenfassung: {ce_summary}
ANSPRECHPARTNER:
- Name: {contact_name}
- Rolle/Position: {role} (WICHTIG: Nutze dieses Wissen für den Tonfall. Ein Geschäftsführer braucht Argumente zu ROI/Effizienz, ein Facility Manager zu Operativem/Handling.)
ANFRAGE-DETAILS (Vom Kunden): ANFRAGE-DETAILS (Vom Kunden):
- Reinigungsfläche: {area} - Reinigungsfläche: {area}
- Einsatzzweck: {purpose} - Einsatzzweck: {purpose}
- Kontaktperson: {contact_name}
DEIN ZIEL: DEIN ZIEL:
Schreibe eine kurze, prägnante und wertschätzende E-Mail. Schreibe eine kurze, prägnante und wertschätzende E-Mail.
1. Bedanke dich für die Anfrage. 1. Bedanke dich für die Anfrage.
2. Zeige kurz, dass du verstanden hast, was die Firma macht (nutze den Kontext aus 'Web-Zusammenfassung' in einem Satz, z.B. "Als führender Anbieter von xyz..."). 2. Zeige kurz, dass du verstanden hast, was die Firma macht.
3. Gehe auf die Fläche ({area}) ein. 3. Gehe auf die Fläche ({area}) ein.
- Wenn > 1000qm oder Industrie/Halle: Erwähne den "Puma M20" oder "Scrubber 75" als Kraftpaket. - Wenn > 1000qm oder Industrie/Halle: Erwähne den "Puma M20" oder "Scrubber 75" als Kraftpaket.
- Wenn < 1000qm oder Büro/Praxis/Gastro: Erwähne den "Phantas" oder "Pudu CC1" als wendige Lösung. - Wenn < 1000qm oder Büro/Praxis/Gastro: Erwähne den "Phantas" oder "Pudu CC1" als wendige Lösung.

View File

@@ -25,13 +25,21 @@ import json
# --- Helper: Get Gemini Key --- # --- Helper: Get Gemini Key ---
def get_gemini_key(): def get_gemini_key():
try: candidates = [
key_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'gemini_api_key.txt') "gemini_api_key.txt", # Current dir
if os.path.exists(key_path): "/app/gemini_api_key.txt", # Docker default
with open(key_path, 'r') as f: os.path.join(os.path.dirname(__file__), "gemini_api_key.txt"), # Script dir
return f.read().strip() os.path.join(os.path.dirname(os.path.dirname(__file__)), 'gemini_api_key.txt') # Parent dir
except: ]
pass
for path in candidates:
if os.path.exists(path):
try:
with open(path, 'r') as f:
return f.read().strip()
except:
pass
return os.getenv("GEMINI_API_KEY") return os.getenv("GEMINI_API_KEY")
def extract_role_with_llm(name, company, search_results): def extract_role_with_llm(name, company, search_results):