Spaces:
Sleeping
Sleeping
feat: introduce configurable content options and privacy controls for spiritual care messages.
Browse filesFiles changed (3)
118 unmodified lines119120121118 unmodified linesstart.sh.zshenvsrc/core/verification_store.py118 unmodified lines119120121122118 unmodified linesstart.sh.zshenvsrc/core/verification_store.pymanual_tests/test_vertex_auth.py
8 unmodified lines9101112131486 unmodified lines1011021031041051061071081091101118 unmodified linesimport osimport jsonimport loggingfrom datetime import datetimefrom typing import Optional, Dict, Any, Listfrom abc import ABC, abstractmethod86 unmodified linesif not GEMINI_AVAILABLE:raise ImportError("Google GenAI library not available. Install with: pip install google-genai")api_key = os.getenv("GEMINI_API_KEY")if not api_key:raise ValueError("GEMINI_API_KEY environment variable not set")self.client = genai.Client(api_key=api_key)self.model_name = model.valuedef generate_response(self, system_prompt: str, user_prompt: str, temperature: Optional[float] = None) -> str:8 unmodified lines91011121314151686 unmodified lines1031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491508 unmodified linesimport osimport jsonimport loggingimport base64import tempfilefrom datetime import datetimefrom typing import Optional, Dict, Any, Listfrom abc import ABC, abstractmethod86 unmodified linesif not GEMINI_AVAILABLE:raise ImportError("Google GenAI library not available. Install with: pip install google-genai")gcp_base64 = os.getenv("GCP_SERVICE_ACCOUNT_B64")api_key = os.getenv("GEMINI_API_KEY")if gcp_base64:try:# Decode Service Account JSON from Base64creds_json = base64.b64decode(gcp_base64).decode('utf-8')# Create temporary file for credentials# Library expects a file path in GOOGLE_APPLICATION_CREDENTIALSself.temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False)self.temp_file.write(creds_json)self.temp_file.flush()os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = self.temp_file.name# Read project_id from credentials to initialize Vertex AIcreds_dict = json.loads(creds_json)project_id = creds_dict.get("project_id")# Initialize client with Vertex AI modeself.client = genai.Client(vertexai=True,project=project_id,location=os.getenv("GOOGLE_CLOUD_LOCATION", "us-central1"))logging.info(f"Initialized Gemini via Vertex AI (Project: {project_id})")except Exception as e:logging.error(f"Error initializing Gemini with Service Account: {e}")# Fallback to API Key if Service Account failsif api_key:self.client = genai.Client(api_key=api_key)logging.info("Fallback: Initialized Gemini via API Key after SA failure")else:raise ValueError(f"Failed to initialize Gemini with Service Account and no API Key found: {e}")elif api_key:# Traditional API Key initializationself.client = genai.Client(api_key=api_key)logging.info("Initialized Gemini via API Key")else:raise ValueError("No Gemini configuration found (GCP_SERVICE_ACCOUNT_B64 or GEMINI_API_KEY)")self.model_name = model.valuedef generate_response(self, system_prompt: str, user_prompt: str, temperature: Optional[float] = None) -> str:
702 unmodified lines703704705706707708709710702 unmodified linesstats,gr.update(visible=show_provider_panel), # provider_summary_content visibilitystatus_msg, # provider_summary_status contentgr.update(value=html_content, visible=True) if show_provider_panel else gr.update(visible=False), # provider_summary_display contentspiritual_care_msg # spiritual_care_message content)def handle_clear(session: SimplifiedSessionData):702 unmodified lines703704705706707708709702 unmodified linesstats,gr.update(visible=show_provider_panel), # provider_summary_content visibilitystatus_msg, # provider_summary_status contentgr.update(value=html_content, visible=True) if show_provider_panel else gr.update(visible=False) # provider_summary_display content)def handle_clear(session: SimplifiedSessionData):
.gitignore+1
src/core/ai_client.py+42-3
src/interface/simplified_gradio_app.py+1-2