-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_qna_endpoint.py
More file actions
58 lines (47 loc) · 1.9 KB
/
test_qna_endpoint.py
File metadata and controls
58 lines (47 loc) · 1.9 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
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Test script for the Q&A endpoint
Tests the search functionality with a real query
"""
import requests
import json
def test_qna_endpoint():
"""Test the Q&A endpoint"""
base_url = "http://localhost:8002"
print("🧪 Testing Q&A Endpoint...")
print("=" * 50)
# Test data
test_data = {
"query": "How does the fraud detection system work?",
"repo_url": "https://github.com/username/real-time-credit-card-fraud-detection-system"
}
try:
print(f"1. Testing Q&A endpoint with query: {test_data['query']}")
print(f" Repository: {test_data['repo_url']}")
response = requests.post(f"{base_url}/search", json=test_data)
if response.status_code == 200:
result = response.json()
print("✅ Q&A endpoint working successfully!")
print(f" Query: {result['query']}")
print(f" Answer: {result['answer'][:200]}...")
print(f" Sources: {result['sources']}")
else:
print(f"❌ Q&A endpoint failed: {response.status_code}")
print(f" Error: {response.text}")
except requests.exceptions.ConnectionError:
print("❌ Cannot connect to server. Make sure it's running on port 8002")
return False
except Exception as e:
print(f"❌ Error testing Q&A endpoint: {e}")
return False
print("\n" + "=" * 50)
print("🎉 Q&A endpoint testing completed!")
return True
if __name__ == "__main__":
success = test_qna_endpoint()
if success:
print("\n🚀 Your Q&A pipeline is working correctly!")
print("🌐 Open your browser and go to: http://localhost:8002")
print("📝 Try asking questions about your code!")
else:
print("\n❌ Q&A testing failed. Check server logs.")