#!/usr/bin/env python3 """ Script to check the current model configuration """ import os import sys from pathlib import Path def check_environment_variables(): """Check environment variables related to model configuration""" print("šŸ” Checking Environment Variables") print("=" * 40) # Check for model-related environment variables model_vars = [ 'DEFAULT_MODEL', 'HUGGINGFACE_API_KEY', 'HUGGINGFAC_API_KEY_2', 'HF_TOKEN', 'MODEL_NAME' ] for var in model_vars: value = os.getenv(var) if value: # Mask API keys for security if 'API_KEY' in var or 'TOKEN' in var: masked_value = value[:10] + "..." + value[-10:] if len(value) > 20 else "***" print(f"āœ… {var}: {masked_value}") else: print(f"āœ… {var}: {value}") else: print(f"āŒ {var}: Not set") def check_app_files(): """Check which app files exist and their model configurations""" print("\nšŸ“ Checking App Files") print("=" * 40) app_files = [ "app.py", "app_backup.py", "api_server.py", "web_app.py" ] for app_file in app_files: if Path(app_file).exists(): print(f"āœ… {app_file}: Exists") # Check for model configuration in the file try: with open(app_file, 'r', encoding='utf-8') as f: content = f.read() # Look for model configuration patterns if 'DEFAULT_MODEL' in content: lines = content.split('\n') for i, line in enumerate(lines): if 'DEFAULT_MODEL' in line and '=' in line: print(f" Model config: {line.strip()}") break except Exception as e: print(f" Error reading file: {e}") else: print(f"āŒ {app_file}: Not found") def check_huggingface_models(): """Check what models are available via Hugging Face""" print("\nšŸ¤— Checking Hugging Face Model Availability") print("=" * 40) try: from huggingface_hub import InferenceClient # Check if we have an API key api_key = os.getenv('HUGGINGFACE_API_KEY') or os.getenv('HF_TOKEN') if not api_key: print("āŒ No Hugging Face API key found") return client = InferenceClient(token=api_key) # Test models test_models = [ "meta-llama/Llama-3.2-1B-Instruct", "meta-llama/Llama-3.1-8B-Instruct", "gpt2", "distilgpt2" ] for model in test_models: try: # Try to create a client with this model test_client = InferenceClient(token=api_key, model=model) print(f"āœ… {model}: Available") except Exception as e: print(f"āŒ {model}: Not available - {str(e)[:100]}...") except ImportError: print("āŒ huggingface_hub not installed") except Exception as e: print(f"āŒ Error checking Hugging Face models: {e}") def main(): print("šŸ”§ Model Configuration Checker") print("=" * 50) check_environment_variables() check_app_files() check_huggingface_models() print("\nšŸ“‹ Summary:") print("- Check the environment variables above") print("- Verify which app file is actually running") print("- Ensure the model is compatible with Hugging Face Inference API") if __name__ == "__main__": main()