76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for the complete system workflow.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Add the current directory to Python path
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from config import Config
|
|
from llm_client import LLMClient
|
|
from interface import TextInterface
|
|
from conversation import ConversationManager
|
|
|
|
|
|
def test_system():
|
|
"""Test the complete system workflow."""
|
|
print("Testing complete system workflow...")
|
|
print("=" * 40)
|
|
|
|
try:
|
|
# Create all components
|
|
print("1. Initializing components...")
|
|
config = Config()
|
|
interface = TextInterface()
|
|
conversation_manager = ConversationManager()
|
|
llm_client = LLMClient(config)
|
|
print(" ✓ Components initialized")
|
|
|
|
# Test connection
|
|
print("\n2. Testing connection to LM Studio...")
|
|
success = llm_client.test_connection()
|
|
if success:
|
|
print(" ✓ Connected to LM Studio")
|
|
else:
|
|
print(" ✗ Failed to connect to LM Studio")
|
|
return
|
|
|
|
# Test message exchange
|
|
print("\n3. Testing message exchange...")
|
|
test_message = "Hello! Can you tell me what you are?"
|
|
conversation_manager.add_user_message(test_message)
|
|
print(f" Sending: {test_message}")
|
|
|
|
response = llm_client.get_response(conversation_manager.get_history())
|
|
conversation_manager.add_assistant_message(response)
|
|
print(f" Received: {response}")
|
|
print(" ✓ Message exchange successful")
|
|
|
|
# Test conversation history
|
|
print("\n4. Testing conversation history...")
|
|
history = conversation_manager.get_history()
|
|
if len(history) == 2:
|
|
print(" ✓ Conversation history maintained")
|
|
else:
|
|
print(" ✗ Conversation history issue")
|
|
return
|
|
|
|
# Test interface (simulated)
|
|
print("\n5. Testing interface components...")
|
|
interface.display_system_message("Interface test successful")
|
|
print(" ✓ Interface components working")
|
|
|
|
print("\n" + "=" * 40)
|
|
print("✓ All tests passed! System is ready for use.")
|
|
|
|
except Exception as e:
|
|
print(f"\n✗ Error during system test: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_system() |