import os from dotenv import load_dotenv from smolagents import LiteLLMModel, OpenAIServerModel from src.tools.project_handler import ProjectHandler from src.ui import AdaAssistantUI from langfuse import get_client from openinference.instrumentation.smolagents import SmolagentsInstrumentor # Load environment variables load_dotenv(override=True) # Initialize Langfuse only for production environment = os.getenv("ENVIRONMENT", "development") if environment == "production": # Verify connection langfuse = get_client() if langfuse.auth_check(): print("Langfuse client is authenticated and ready!") else: print("Authentication failed. Please check your credentials and host.") SmolagentsInstrumentor().instrument() else: print("Development mode: Langfuse integration disabled") def initialize_project_handler(): """Initialize the ProjectHandler with appropriate model""" temperature = 0.1 if environment == "production": model_id = os.getenv("PRODUCTION_MODEL_ID", "gpt-4o-mini") model = OpenAIServerModel( model_id=model_id, api_key=os.environ["OPENAI_API_KEY"], temperature=temperature ) else: model_id = os.getenv("DEVELOPMENT_MODEL_ID", "ollama/llama3.2") model = LiteLLMModel( model_id=model_id, temperature=temperature ) project_handler = ProjectHandler(model) return project_handler # Create Gradio interface if __name__ == "__main__": project_handler = initialize_project_handler() ui = AdaAssistantUI(project_handler) app = ui.create_interface() app.launch()