Spaces:
Sleeping
Sleeping
File size: 1,695 Bytes
2754850 |
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 51 52 53 54 55 |
#!/usr/bin/env python3
"""
Test script to verify AI chat integration is working
"""
import requests
import json
def test_chat_ai():
base_url = "https://harismlnaslm-Textilindo-AI.hf.space"
print("π€ Testing AI Chat Integration")
print("=" * 50)
# Test questions
test_questions = [
"Jam berapa Textilindo buka?",
"dimana lokasi textilindo?",
"apa ada gratis ongkir?",
"berapa ketentuan pembelian?",
"apa bisa dikirimkan sample?"
]
for i, question in enumerate(test_questions, 1):
print(f"\n{i}οΈβ£ Testing: '{question}'")
try:
response = requests.post(
f"{base_url}/chat",
json={"message": question},
headers={"Content-Type": "application/json"}
)
if response.status_code == 200:
data = response.json()
ai_response = data.get('response', 'No response')
print(f"β
AI Response: {ai_response}")
# Check if response is relevant
if question.lower() in ai_response.lower() or any(word in ai_response.lower() for word in question.lower().split()):
print("β
Response appears relevant")
else:
print("β οΈ Response might not be relevant")
else:
print(f"β Error: {response.status_code} - {response.text}")
except Exception as e:
print(f"β Error: {e}")
print("\nπ Chat AI Test Complete!")
if __name__ == "__main__":
test_chat_ai()
|