KinglyWayne/esg-rag-platform
0
1import requests2 3API_ENDPOINT = "http://54.254.230.28:8888"4 5# function to call api6def call_api_stream(api_path, api_params):7 session = requests.Session()8 url = f"{API_ENDPOINT}/{api_path}"9 response = session.post(10 url, json=api_params, headers={"Content-Type": "application/json"},11 stream=True12 )13 return response14 15def call_api(api_path, api_params):16 session = requests.Session()17 url = f"{API_ENDPOINT}/{api_path}"18 response = session.post(19 url, json=api_params, headers={"Content-Type": "application/json"}20 )21 return response.json()22 23def api_rag_qa_chain_demo(openai_model_name, query, year, target_type, target_value, history):24 # api_path = "qa/demo"25 api_path = "qa/demo/test-feature"26 api_params = {27 "openai_model_name": openai_model_name,28 "query": query,29 "year": year,30 "target_type": target_type,31 "target_value": target_value,32 "prev_turn_of_conversation": history,33 }34 return call_api_stream(api_path, api_params)35 36def api_rag_summ_chain_demo(openai_model_name, query, year, target_type, target_value, tone):37 # api_path = "summary/demo"38 api_path = "summary/demo/test-feature"39 api_params = {40 "openai_model_name": openai_model_name,41 "query": query,42 "year": year,43 "target_type": target_type,44 "target_value": target_value,45 "tone": tone,46 }47 return call_api_stream(api_path, api_params)48 