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", {})