-
Notifications
You must be signed in to change notification settings - Fork 1
/
API_calls.py
53 lines (47 loc) · 1.21 KB
/
API_calls.py
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
import requests
import json
# Define the API endpoint
api_endpoint = "http://127.0.0.1:9090/search"
# Define the model name
model_name = "LaBSE"
# Function to perform API requests and print results
def perform_search_case(case_data, case_name):
headers = {
"Content-Type": "application/json"
}
# Include the model_name in the case data
print("Querying", case_data)
response = requests.post(api_endpoint, headers=headers, data=json.dumps(case_data))
if response.status_code == 200:
print(f"{case_name}:")
print(json.dumps(response.json(), indent=2))
else:
print(f"{case_name} failed with status code {response.status_code}:")
print(response.text)
case_4 = {
"model_name": "LaBSE",
"term": "Date",
"context": {
"domain": "person",
},
"filters": {
"datatype": "something"
}
}
perform_search_case(case_4, "CASE 4")
case_5 = {
"model_name": "LaBSE",
"term": "Date",
"context": {
"domain": "creative work",
},
"filters": {
"datatype": "object_property"
}
}
perform_search_case(case_5, "CASE 5")
case_6 = {
"model_name": "LaBSE",
"term": "Date",
}
perform_search_case(case_6, "CASE 6")