"""Common utility functions for the Medical Simulation Suite AI.This module provides helper functions for initializing models and knowledge bases,reading all configurations from the central config file."""importloggingfromtypingimportUnionfromagno.models.anthropicimportClaudefromagno.models.googleimportGeminifromagno.vectordb.chromaimportChromaDbfromagno.knowledge.jsonimportJSONKnowledgeBasefromagno.embedder.googleimportGeminiEmbedderfromagno.document.chunking.recursiveimportRecursiveChunkingfromconfigimportMODEL_CONFIG,USE_ANTHROPIC,AI_PROVIDERembedder=GeminiEmbedder()vector_db=ChromaDb(collection="sim_suite_data",path="data/chromadb/general",persistent_client=True,embedder=embedder)knowledge_base=JSONKnowledgeBase(path="./data/case_studies/",vector_db=vector_db,chunking_strategy=RecursiveChunking())report_vector_db=ChromaDb(collection="sim_suite_reports",path="data/chromadb/reports",persistent_client=True,embedder=embedder)report_knowledge_base=JSONKnowledgeBase(path="./data/reports/",vector_db=report_vector_db,chunking_strategy=RecursiveChunking())logger=logging.getLogger(__name__)logger.info(f"AI Provider selected based on API keys: {AI_PROVIDER}")
[docs]defget_big_model()->Union[Gemini,Claude]:""" Initializes and returns the primary generation model based on the centralized configuration. """ifUSE_ANTHROPIC:model_name=MODEL_CONFIG["claude_big"]logger.info(f"Initializing BIG model: Claude ('{model_name}')")returnClaude(model_name)else:model_name=MODEL_CONFIG["gemini_big"]logger.info(f"Initializing BIG model: Gemini ('{model_name}')")returnGemini(model_name)
[docs]defget_small_model()->Union[Gemini,Claude]:""" Initializes and returns the smaller/faster model based on the centralized configuration. """ifUSE_ANTHROPIC:model_name=MODEL_CONFIG["claude_small"]logger.info(f"Initializing SMALL model: Claude ('{model_name}')")returnClaude(model_name)else:model_name=MODEL_CONFIG["gemini_small"]logger.info(f"Initializing SMALL model: Gemini ('{model_name}')")returnGemini(model_name)
[docs]defget_knowledge_base()->JSONKnowledgeBase:"""Provides access to the knowledge base."""returnknowledge_base
[docs]defget_report_knowledge_base()->JSONKnowledgeBase:"""Provides access to the report knowledge base."""returnreport_knowledge_base