Download scripts/dev/1_test_node_creation.py from SlappAI/Singularity: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/SlappAI/Singularity/resolve/c8aa03645367f13b28133e72d9204fa09654b00a/scripts/dev/1_test_node_creation.py
- Command line
-
hf download hf://SlappAI/Singularity@c8aa03645367f13b28133e72d9204fa09654b00a/scripts/dev/1_test_node_creation.py
-
curl -L -o 1_test_node_creation.py https://huggingface.co/SlappAI/Singularity/resolve/c8aa03645367f13b28133e72d9204fa09654b00a/scripts/dev/1_test_node_creation.py
1.54 kB
| import requests | |
| import json | |
| BASE_URL = "http://localhost:5000" | |
| def test_load_graph(): | |
| response = requests.post(f"{BASE_URL}/load_graph") | |
| print("Load Graph Response:", response.json()) | |
| def test_create_node(): | |
| payload = { | |
| "node_id": "patient_123", | |
| "data": { | |
| "name": "John Doe", | |
| "age": 45, | |
| "medical_conditions": ["hypertension", "diabetes"] | |
| }, | |
| "domain": "Healthcare", | |
| "type": "Patient" | |
| } | |
| headers = {"Content-Type": "application/json"} | |
| response = requests.post(f"{BASE_URL}/create_node", headers=headers, data=json.dumps(payload)) | |
| print("Create Node Response:", response.json()) | |
| def test_query_node(node_id): | |
| response = requests.get(f"{BASE_URL}/query_node", params={"node_id": node_id}) | |
| print(f"Query Node {node_id} Response:", response.json()) | |
| def test_list_nodes(): | |
| response = requests.get(f"{BASE_URL}/list_nodes") | |
| print("List Nodes Response:", response.json()) | |
| def test_list_relationships(): | |
| response = requests.get(f"{BASE_URL}/list_relationships") | |
| print("List Relationships Response:", response.json()) | |
| if __name__ == "__main__": | |
| print("\n--- Testing Graph Loading ---") | |
| test_load_graph() | |
| print("\n--- Testing Node Creation ---") | |
| test_create_node() | |
| print("\n--- Testing Node Query ---") | |
| test_query_node("patient_123") | |
| print("\n--- Testing List All Nodes ---") | |
| test_list_nodes() | |
| print("\n--- Testing List All Relationships ---") | |
| test_list_relationships() |