| | import sys |
| | from pathlib import Path |
| |
|
| | |
| | project_root = Path(__file__).parent |
| | sys.path.append(str(project_root)) |
| |
|
| | from core.redis_client import redis_client |
| | import requests |
| | import json |
| |
|
| | def quick_test(): |
| | """Quick test of core components""" |
| | print("=== Quick System Test ===") |
| | print() |
| | |
| | |
| | print("1. Testing Redis...") |
| | try: |
| | client = redis_client.get_client() |
| | if client and client.ping(): |
| | print("β
Redis connection successful") |
| | |
| | |
| | test_data = { |
| | "name": "test_user", |
| | "messages": json.dumps([]), |
| | "created_at": "2025-09-08" |
| | } |
| | |
| | result = client.hset("test:user:123", mapping=test_data) |
| | retrieved = client.hgetall("test:user:123") |
| | client.delete("test:user:123") |
| | |
| | if retrieved: |
| | print("β
Redis data storage working") |
| | else: |
| | print("β Redis data storage failed") |
| | else: |
| | print("β Redis connection failed") |
| | except Exception as e: |
| | print(f"β Redis test failed: {e}") |
| | |
| | print() |
| | |
| | |
| | print("2. Testing Ollama...") |
| | try: |
| | ollama_url = "https://7bcc180dffd1.ngrok-free.app" |
| | headers = { |
| | "ngrok-skip-browser-warning": "true", |
| | "User-Agent": "AI-Life-Coach-Test" |
| | } |
| | |
| | |
| | response = requests.get(f"{ollama_url}/api/tags", headers=headers, timeout=10) |
| | if response.status_code == 200: |
| | print("β
Ollama model listing successful") |
| | |
| | |
| | payload = { |
| | "model": "mistral:latest", |
| | "messages": [{"role": "user", "content": "Hello!"}], |
| | "stream": False |
| | } |
| | |
| | chat_response = requests.post( |
| | f"{ollama_url}/api/chat", |
| | headers=headers, |
| | json=payload, |
| | timeout=30 |
| | ) |
| | |
| | if chat_response.status_code == 200: |
| | print("β
Ollama chat successful") |
| | else: |
| | print(f"β Ollama chat failed: {chat_response.status_code}") |
| | else: |
| | print(f"β Ollama connection failed: {response.status_code}") |
| | |
| | except Exception as e: |
| | print(f"β Ollama test failed: {e}") |
| | |
| | print() |
| | print("π Quick test completed!") |
| |
|
| | if __name__ == "__main__": |
| | quick_test() |
| |
|