FinHight / test_fingpt_integration.py
Starfish55's picture
Upload 8 files
23c518c verified
#!/usr/bin/env python3
"""
Test script to verify FinGPT integration
"""
import os
import sys
def test_imports():
"""Test if all required imports work"""
try:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
print("βœ… All FinGPT imports successful")
return True
except ImportError as e:
print(f"❌ Import error: {e}")
return False
def test_model_config():
"""Test model configuration"""
try:
# Test if we can access the model configuration
FINGPT_MODEL_NAME = "Starfish55/fingpt-complete"
print(f"βœ… Model configuration: {FINGPT_MODEL_NAME}")
return True
except Exception as e:
print(f"❌ Model configuration error: {e}")
return False
def test_app_import():
"""Test if the main app can be imported"""
try:
# Add current directory to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# Import the main app
import app
print("βœ… App import successful")
return True
except Exception as e:
print(f"❌ App import error: {e}")
return False
def main():
"""Run all tests"""
print("πŸ§ͺ Testing FinGPT Integration...")
print("=" * 50)
tests = [
test_imports,
test_model_config,
test_app_import
]
passed = 0
total = len(tests)
for test in tests:
if test():
passed += 1
print()
print("=" * 50)
print(f"πŸ“Š Test Results: {passed}/{total} tests passed")
if passed == total:
print("πŸŽ‰ All tests passed! FinGPT integration is ready.")
else:
print("⚠️ Some tests failed. Please check the errors above.")
return passed == total
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)