Spaces:
Sleeping
Sleeping
File size: 4,143 Bytes
24214fc e8c7fad 24214fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
#!/usr/bin/env python3
"""
Test script for enhanced prompt optimization integration.
"""
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'src'))
def test_integration():
"""Test the integration of enhanced prompt editor with the main app."""
print("π§ͺ Testing Enhanced Prompt Optimization Integration")
print("=" * 60)
try:
# Test 1: Import all components
print("1. Testing imports...")
from interface.enhanced_prompt_editor import EnhancedPromptEditor
from config.prompt_management.prompt_controller import PromptController
from interface.gradio_app import main
print(" β All components import successfully")
# Test 2: Initialize components
print("\n2. Testing component initialization...")
editor = EnhancedPromptEditor()
controller = PromptController()
print(" β Components initialize successfully")
# Test 3: Test prompt loading
print("\n3. Testing prompt loading...")
prompts = editor.get_available_prompts()
print(f" β Found {len(prompts)} available prompts:")
for prompt in prompts:
print(f" - {prompt}")
# Test 4: Test session override functionality
print("\n4. Testing session override functionality...")
session_id = "integration_test_session"
test_content = "Test session override content for integration testing"
# Load original prompt
original_content, _, _ = editor.load_prompt_for_editing(
"π Spiritual Monitor (Classifier)",
session_id
)
print(f" β Original prompt loaded: {len(original_content)} chars")
# Apply session override
status_html, success = editor.apply_prompt_changes(
"π Spiritual Monitor (Classifier)",
test_content,
session_id
)
print(f" β Session override applied: {success}")
# Verify override is active
override_content, _, _ = editor.load_prompt_for_editing(
"π Spiritual Monitor (Classifier)",
session_id
)
override_active = test_content in override_content
print(f" β Session override active: {override_active}")
# Test reset functionality
reset_content, _, _ = editor.reset_prompt_to_default(
"π Spiritual Monitor (Classifier)",
session_id
)
reset_successful = test_content not in reset_content
print(f" β Reset to default works: {reset_successful}")
# Test 5: Test validation
print("\n5. Testing prompt validation...")
validation_html, is_valid = editor.validate_prompt_syntax(original_content)
print(f" β Validation works: {is_valid}")
# Test 6: Test session status
print("\n6. Testing session status...")
# Set override again for status test
editor.apply_prompt_changes(
"π Spiritual Monitor (Classifier)",
test_content,
session_id
)
status_html = editor.get_session_prompt_status(session_id)
has_overrides = "Active Session Overrides" in status_html
print(f" β Session status tracking: {has_overrides}")
print("\n" + "=" * 60)
print("π ALL INTEGRATION TESTS PASSED!")
print("\nπ Summary:")
print(" β
Enhanced prompt editor fully integrated")
print(" β
Session-level prompt overrides working")
print(" β
Validation and status tracking functional")
print(" β
Reset and promotion workflows ready")
print("\nπ Ready to launch the enhanced medical assistant!")
return True
except Exception as e:
print(f"\nβ Integration test failed: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
success = test_integration()
sys.exit(0 if success else 1) |