-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-ollama.py
More file actions
50 lines (47 loc) · 1.61 KB
/
test-ollama.py
File metadata and controls
50 lines (47 loc) · 1.61 KB
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
#!/usr/bin/env python3
"""
Quick test to verify Ollama is running and accessible
"""
import requests
import json
def test_ollama_connection():
try:
# Test if Ollama is running
response = requests.get("http://localhost:11434/api/tags")
if response.status_code == 200:
models = response.json()
print("✅ Ollama is running!")
print(f"Available models: {[model['name'] for model in models['models']]}")
return True
else:
print("❌ Ollama is not responding")
return False
except Exception as e:
print(f"❌ Cannot connect to Ollama: {e}")
print("Make sure Ollama is installed and running with 'ollama serve'")
return False
def test_llm_generation():
try:
# Test generating a response
data = {
"model": "llama3",
"prompt": "Generate a CSS selector for a login button",
"stream": False
}
response = requests.post("http://localhost:11434/api/generate", json=data)
if response.status_code == 200:
result = response.json()
print("✅ LLM Generation working!")
print(f"Response: {result['response'][:100]}...")
return True
else:
print("❌ LLM Generation failed")
return False
except Exception as e:
print(f"❌ LLM test failed: {e}")
return False
if __name__ == "__main__":
print("🔍 Testing Ollama Connection...")
if test_ollama_connection():
print("\n🤖 Testing LLM Generation...")
test_llm_generation()