Singtel_Use_Case1 / test_ollama.py
cosmoruler
stuck already
db6dcad
raw
history blame contribute delete
999 Bytes
#!/usr/bin/env python3
"""
Simple test to verify Ollama integration
"""
import ollama
def test_ollama():
print("πŸ” Testing Ollama integration...")
try:
# Test connection
models = ollama.list()
print(f"βœ… Ollama is accessible! Found {len(models['models'])} models:")
for model in models['models']:
model_name = model.get('name', model.get('model', 'Unknown'))
print(f" πŸ“¦ {model_name}")
# Test generation
print("\nπŸ€– Testing AI generation...")
response = ollama.generate(
model='llama2',
prompt='Hello! Can you analyze data? Please respond briefly.'
)
print("βœ… AI Response:")
print("-" * 40)
print(response['response'])
print("-" * 40)
return True
except Exception as e:
print(f"❌ Ollama test failed: {e}")
return False
if __name__ == "__main__":
test_ollama()