Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python3 | |
| """ | |
| Test script to verify llama.cpp installation | |
| """ | |
| def test_llamacpp_import(): | |
| """Test if llama-cpp-python can be imported""" | |
| try: | |
| from llama_cpp import Llama | |
| print("β llama-cpp-python imported successfully") | |
| return True | |
| except ImportError as e: | |
| print(f"β Failed to import llama-cpp-python: {e}") | |
| return False | |
| def test_basic_functionality(): | |
| """Test basic llama.cpp functionality without a model""" | |
| try: | |
| from llama_cpp import Llama | |
| print("β llama.cpp classes accessible") | |
| # Test that we can access the Llama class attributes | |
| print("β Llama class instantiable (without model)") | |
| return True | |
| except Exception as e: | |
| print(f"β Error testing basic functionality: {e}") | |
| return False | |
| def test_dependencies(): | |
| """Test other required dependencies""" | |
| dependencies = [ | |
| "gradio", | |
| "numpy", | |
| "json", | |
| "huggingface_hub" | |
| ] | |
| all_good = True | |
| for dep in dependencies: | |
| try: | |
| __import__(dep) | |
| print(f"β {dep} imported successfully") | |
| except ImportError as e: | |
| print(f"β Failed to import {dep}: {e}") | |
| all_good = False | |
| return all_good | |
| if __name__ == "__main__": | |
| print("Testing llama.cpp installation for Hugging Face Space...") | |
| print("=" * 60) | |
| tests = [ | |
| ("llama-cpp-python import", test_llamacpp_import), | |
| ("Basic functionality", test_basic_functionality), | |
| ("Dependencies", test_dependencies), | |
| ] | |
| results = [] | |
| for test_name, test_func in tests: | |
| print(f"\nπ§ͺ Running: {test_name}") | |
| result = test_func() | |
| results.append(result) | |
| print("\n" + "=" * 60) | |
| print("Test Summary:") | |
| if all(results): | |
| print("π All tests passed! llama.cpp is ready for use.") | |
| else: | |
| print("β οΈ Some tests failed. Check the output above.") | |
| print("This might be expected if running before dependencies are installed.") |