Spaces:
Runtime error
Runtime error
File size: 1,677 Bytes
4f0769b ddf85e5 4f0769b c0d38ef 4f0769b c0d38ef 4f0769b c0d38ef 4f0769b ea84703 4f0769b c0d38ef 4f0769b ea84703 4f0769b c0d38ef 4f0769b 9fbf2b6 4f0769b 3349d08 4f0769b ddf85e5 4f0769b 3349d08 |
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 59 60 |
import requests
API_ENDPOINT = "http://35.229.175.237:8889"
# function to call api
def call_api_stream(api_path, api_params):
session = requests.Session()
url = f"{API_ENDPOINT}/{api_path}"
response = session.post(
url, json=api_params, headers={"Content-Type": "application/json"},
stream=True
)
return response
def call_api(api_path, api_params):
session = requests.Session()
url = f"{API_ENDPOINT}/{api_path}"
response = session.post(
url, json=api_params, headers={"Content-Type": "application/json"}
)
return response.json()
def api_qa_normal(query, filtered_data):
api_path = "qa/normal"
api_params = {
"query": query,
"filtered_data": filtered_data,
}
return call_api_stream(api_path, api_params)
def api_qa_waterfee(query, filtered_data):
api_path = "qa/waterfee"
api_params = {
"query": query,
"filtered_data": filtered_data,
}
return call_api_stream(api_path, api_params)
def api_qa_cat_report(filtered_data):
api_path = "qa/catreportexplain"
api_params = {
"filtered_data": filtered_data,
}
return call_api_stream(api_path, api_params)
def api_ocr(image_filepath, model_provider):
api_path = "ocr"
api_params = {
"image_filepath": image_filepath,
"model_provider": model_provider
}
return call_api(api_path, api_params).get("text_result", "")
def api_model_cat_pain_assessment(user_input_image):
api_path = "model/cat-pain-assessment"
api_params = {
"user_input_image": user_input_image
}
return call_api(api_path, api_params).get("json_result", {})
|