Spaces:
Sleeping
Sleeping
File size: 1,394 Bytes
84e90e4 1ae130a 84e90e4 1ae130a d244f70 84e90e4 1ae130a ae46567 84e90e4 1ae130a 84e90e4 |
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 |
import requests
API_ENDPOINT = "http://54.254.230.28:8888"
# 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_rag_qa_chain_demo(openai_model_name, query, year, target_type, target_value, history):
api_path = "qa/demo"
api_params = {
"openai_model_name": openai_model_name,
"query": query,
"year": year,
"target_type": target_type,
"target_value": target_value,
"prev_turn_of_conversation": history,
}
return call_api_stream(api_path, api_params)
def api_rag_summ_chain_demo(openai_model_name, query, year, target_type, target_value, tone):
api_path = "summary/demo"
api_params = {
"openai_model_name": openai_model_name,
"query": query,
"year": year,
"target_type": target_type,
"target_value": target_value,
"tone": tone,
}
return call_api_stream(api_path, api_params)
|