[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

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