|
|
| import os
|
| import streamlit as st
|
| import logging
|
|
|
|
|
| APP_TITLE = "AI Chat & Blood Classifier"
|
| PAGE_LAYOUT = "wide"
|
| INITIAL_SIDEBAR_STATE = "auto"
|
|
|
|
|
| try:
|
| GOOGLE_API_KEY = st.secrets["GOOGLE_API_KEY"]
|
| except KeyError:
|
| st.error("❌ Google API Key not found in Streamlit secrets. Please add GOOGLE_API_KEY='YourKey' to .streamlit/secrets.toml")
|
| st.stop()
|
| except Exception as e:
|
| st.error(f"❌ Error accessing Streamlit secrets: {e}")
|
| st.stop()
|
|
|
| GEMINI_MODEL_NAME = "gemini-1.5-flash"
|
| EMBEDDING_MODEL_NAME = "models/text-embedding-004"
|
|
|
|
|
|
|
| BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
| BLOOD_DISEASE_MODEL_PATH = os.path.join(BASE_DIR, 'blood_cells_model.h5')
|
| CELL_TYPE_MODEL_PATH = os.path.join(BASE_DIR, 'image_classification_model.h5')
|
| DATA_FILE_PATH = os.path.join(BASE_DIR, 'data.txt')
|
| FAISS_INDEX_PATH = os.path.join(BASE_DIR, 'faiss_index.bin')
|
| FAISS_METADATA_PATH = os.path.join(BASE_DIR, 'faiss_metadata.pkl')
|
|
|
|
|
|
|
| DISEASE_INDICATOR_CLASS_NAMES = ["RUNX1_RUNX1T1", "control", "NPM1", "PML_RARA"]
|
|
|
| CELL_TYPE_CLASS_NAMES = ["ig", "lymphocyte", "monocyte", "neutrophil", "platelet"]
|
|
|
|
|
| BLOOD_DISEASE_TARGET_SIZE = (224, 224)
|
| CELL_TYPE_TARGET_SIZE = (64, 64)
|
|
|
|
|
| EMBEDDING_DIMENSION = 768
|
|
|
|
|
| HOSPITAL_CACHE_DURATION = 86400
|
|
|
|
|
| LOGGING_LEVEL = logging.INFO
|
| LOGGING_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
|
| def setup_logging():
|
| """Configures the application's logger."""
|
| logging.basicConfig(level=LOGGING_LEVEL, format=LOGGING_FORMAT)
|
| logger = logging.getLogger('bloodcell_app')
|
| return logger
|
|
|
|
|
| AVAILABLE_LOCATIONS = ["Lahore", "Karachi", "Islamabad", "Multan", "Faisalabad", "Peshawar"] |