Spaces:
Running
Running
Download backend/test_api.py from Turab0104/scaler-backend: direct link, hf CLI and curl.
- Browser
- Download file 2.09 kB
-
https://huggingface.co/spaces/Turab0104/scaler-backend/resolve/main/backend/test_api.py
- Command line
-
hf download hf://spaces/Turab0104/scaler-backend/backend/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/Turab0104/scaler-backend/resolve/main/backend/test_api.py
2.09 kB
| from fastapi.testclient import TestClient | |
| from main import app | |
| client = TestClient(app) | |
| def run_test(): | |
| print("========================================") | |
| print("Test 1: Global Search - LangGraph") | |
| print("========================================") | |
| payload1 = { | |
| "query": "Why did Turab use LangGraph?", | |
| "project_hint": None | |
| } | |
| response1 = client.post("/search_knowledge", json=payload1) | |
| data1 = response1.json() | |
| print(f"Status Code: {response1.status_code}") | |
| print(f"Retrieval Mode: {data1['retrieval_mode']}") | |
| print(f"Project Detected: {data1['project_detected']}") | |
| print(f"Number of chunks: {len(data1['chunks'])}") | |
| print(f"Sample snippet of top chunk: {data1['chunks'][0][:200]}...") | |
| print("\n========================================") | |
| print("Test 2: Filtered Search - OmniMed") | |
| print("========================================") | |
| payload2 = { | |
| "query": "What challenge did OmniMed face?", | |
| "project_hint": "omnimed" | |
| } | |
| response2 = client.post("/search_knowledge", json=payload2) | |
| data2 = response2.json() | |
| print(f"Status Code: {response2.status_code}") | |
| print(f"Retrieval Mode: {data2['retrieval_mode']}") | |
| print(f"Project Detected: {data2['project_detected']}") | |
| print(f"Number of chunks: {len(data2['chunks'])}") | |
| print(f"Sample snippet of top chunk: {data2['chunks'][0][:200]}...") | |
| print("\n========================================") | |
| print("Test 3: Bait Question - GPA") | |
| print("========================================") | |
| payload3 = { | |
| "query": "What was Turab's GPA?", | |
| "project_hint": None | |
| } | |
| response3 = client.post("/search_knowledge", json=payload3) | |
| data3 = response3.json() | |
| print(f"Status Code: {response3.status_code}") | |
| print(f"Retrieval Mode: {data3['retrieval_mode']}") | |
| print(f"Project Detected: {data3['project_detected']}") | |
| print(f"Number of chunks: {len(data3['chunks'])}") | |
| print(f"Sample snippet of top chunk: {data3['chunks'][0][:200]}...") | |
| if __name__ == "__main__": | |
| run_test() | |