#!/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()