#!/usr/bin/env python3
import requests

class EdenSystemAdapter:
    def __init__(self):
        self.url = "http://localhost:11434/api/generate"
        self.model = "llama3.1:8b"
        print("🔧 Connecting to Ollama at localhost:11434...")
    
    def respond(self, prompt):
        try:
            response = requests.post(
                self.url,
                json={
                    "model": self.model,
                    "prompt": prompt,
                    "stream": False
                },
                timeout=60
            )
            return response.json()["response"]
        except Exception as e:
            return f"ERROR: {e}"

if __name__ == "__main__":
    from simple_capability_tests import SimpleCapabilityTest
    
    print("\n" + "="*70)
    print("TESTING EDEN CONNECTION")
    print("="*70)
    
    eden = EdenSystemAdapter()
    
    # Quick connection test
    print("\nTesting connection with: 'What is 2 + 2?'")
    test_response = eden.respond("What is 2 + 2?")
    print(f"Response: {test_response[:100]}...")
    
    if "4" in test_response:
        print("\n✅ Connection working!")
        input("\nPress Enter to run capability tests...")
        tester = SimpleCapabilityTest(eden)
        tester.run_all_tests()
    else:
        print("\n⚠️ Connection issue")
        print("Make sure Ollama is running: ollama serve")
