File size: 1,296 Bytes
84e90e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d244f70
84e90e4
 
 
 
 
 
d244f70
84e90e4
 
 
 
ae46567
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
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, company_name, history):
    api_path = "qa/demo"
    api_params = {
        "openai_model_name": openai_model_name,
        "query": query,
        "year": year,
        "company_name": company_name,
        "prev_turn_of_conversation": history,
    }
    return call_api_stream(api_path, api_params)

def api_rag_summ_chain_demo(openai_model_name, query, year, company_name, tone):
    api_path = "summary/demo"
    api_params = {
        "openai_model_name": openai_model_name,
        "query": query,
        "year": year,
        "company_name": company_name,
        "tone": tone,
    }
    return call_api_stream(api_path, api_params)