INNER CODE UNIT · Python

init_components

SPThole/CoexistAI · app.py:32

def init_components():
    """(Re)initialize model and embedding components from model_config. This is safe to call
    at startup or after config reload. It updates module-level globals used by request handlers.
    """
    global llm, hf_embeddings, cross_encoder, text_splitter, searcher, date, day, llm_model_name, llm_type, llm_kwargs, embedding_model_name, embed_mode, cross_encoder_name

    app_state['status'] = 'starting'
    app_state['message'] = 'Loading models and embeddings (this may take a minute)...'
    print("=== CoexistAI Startup: Loading models and embeddings ===", flush=True)
    try:
        # Read config values
        print("Reading configuration from model_config...", flush=True)
        llm_model_name = model_config.get("llm_model_name", llm_model_name if 'llm_model_name' in globals() else 'google/gemma-3-12b')
        llm_type = model_config.get("llm_type", llm_type if 'llm_type' in globals() else 'local')
        llm_kwargs = model_config.get("llm_kwargs", llm_kwargs if 'llm_kwargs' in globals() else {'temperature':0.1,'api_key': llm_api_key})

        embedding_model_name = model_config.get("embedding_model_name", embedding_model_name if 'embedding_model_name' in globals() else 'models/embedding-001')
        embed_mode = model_config.get("embed_mode", embed_mode if 'embed_mode' in globals() else 'google')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…