fix(deps): Migrate from google.generativeai to google-genai
- Updates requirements.txt to use the new 'google-genai' package. - Updates import statements and error messages in helpers.py to use the new library. - Ensures the gemini_api_key.txt is copied into the Docker container to resolve API key errors.
This commit is contained in:
@@ -36,6 +36,7 @@ COPY helpers.py .
|
|||||||
COPY config.py .
|
COPY config.py .
|
||||||
# Use the specific requirements file for this app
|
# Use the specific requirements file for this app
|
||||||
COPY gtm-architect/requirements.txt .
|
COPY gtm-architect/requirements.txt .
|
||||||
|
COPY gemini_api_key.txt .
|
||||||
COPY gtm_db_manager.py .
|
COPY gtm_db_manager.py .
|
||||||
|
|
||||||
# Install Python and Node.js dependencies
|
# Install Python and Node.js dependencies
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
google-generativeai
|
google-genai
|
||||||
requests
|
requests
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
werkzeug
|
werkzeug
|
||||||
|
|||||||
16
helpers.py
16
helpers.py
@@ -52,11 +52,13 @@ except ImportError:
|
|||||||
|
|
||||||
# --- KI UMSCHALTUNG: Google Generative AI statt OpenAI ---
|
# --- KI UMSCHALTUNG: Google Generative AI statt OpenAI ---
|
||||||
try:
|
try:
|
||||||
import google.generativeai as genai
|
# Versuche, die neue, empfohlene Bibliothek zu importieren
|
||||||
|
import google.genai as genai
|
||||||
HAS_GEMINI = True
|
HAS_GEMINI = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_GEMINI = False
|
HAS_GEMINI = False
|
||||||
logging.warning("google-generativeai Bibliothek nicht gefunden. KI-Funktionen deaktiviert.")
|
genai = None # Sicherstellen, dass genai definiert ist
|
||||||
|
logging.warning("google-genai Bibliothek nicht gefunden. KI-Funktionen deaktiviert.")
|
||||||
|
|
||||||
# OpenAI Imports entfernen wir oder machen sie optional, um Verwirrung zu vermeiden
|
# OpenAI Imports entfernen wir oder machen sie optional, um Verwirrung zu vermeiden
|
||||||
try:
|
try:
|
||||||
@@ -312,11 +314,9 @@ def call_gemini_flash(prompt, system_instruction=None, temperature=0.3, json_mod
|
|||||||
Spezifische Funktion für Gemini 1.5 Flash Aufrufe mit System-Instruction Support.
|
Spezifische Funktion für Gemini 1.5 Flash Aufrufe mit System-Instruction Support.
|
||||||
Wird vom GTM Architect Orchestrator verwendet.
|
Wird vom GTM Architect Orchestrator verwendet.
|
||||||
"""
|
"""
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
if not HAS_GEMINI:
|
if not HAS_GEMINI:
|
||||||
logger.error("Fehler: google-generativeai Bibliothek fehlt.")
|
logger.error("Fehler: google-genai Bibliothek fehlt.")
|
||||||
raise ImportError("google-generativeai not installed.")
|
raise ImportError("google-genai not installed.")
|
||||||
|
|
||||||
api_key = _get_gemini_api_key()
|
api_key = _get_gemini_api_key()
|
||||||
genai.configure(api_key=api_key)
|
genai.configure(api_key=api_key)
|
||||||
@@ -364,8 +364,8 @@ def call_openai_chat(prompt, temperature=0.3, model=None, response_format_json=F
|
|||||||
api_key = _get_gemini_api_key()
|
api_key = _get_gemini_api_key()
|
||||||
|
|
||||||
if not HAS_GEMINI:
|
if not HAS_GEMINI:
|
||||||
logger.error("Fehler: google-generativeai Bibliothek fehlt.")
|
logger.error("Fehler: google-genai Bibliothek fehlt.")
|
||||||
raise ImportError("google-generativeai not installed.")
|
raise ImportError("google-genai not installed.")
|
||||||
|
|
||||||
# Konfiguriere Gemini
|
# Konfiguriere Gemini
|
||||||
genai.configure(api_key=api_key)
|
genai.configure(api_key=api_key)
|
||||||
|
|||||||
Reference in New Issue
Block a user