QCDIS / NaaVRE

BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Query reformulation UI #425

Closed skoulouzis closed 1 year ago

skoulouzis commented 1 year ago

UI design

Image

API usage example:

def query_reformulation(api_endpoint, api_config): 
    ''' test query reformulation API with `POST` method
    Note it shares the same API endpoint with query generation, 
    but instead of using cell contents to generate queries, 
    it uses user's query. 
    '''
    url = api_endpoint + "query_generation/"
    client_id = 'kitten'
    event = "query_reformulation"
    cell_contents = [
        {
            "cell_type": "user query",
            "cell_content": "Great empire conquer marz", 
        }, 
        ]
    data = {
        "client_id": client_id, 
        "timestamp": str(time.time()), 
        "event": event, 
        "cell_contents": cell_contents, 
    }
    # print(json.dumps(data))
    response = requests.post(url, json=data, **api_config)
    results = response.json()
    print('------------------------ Reformulated quries results -----------------------\n')
    pprint(results['generated_queries'][0]['queries'])
    print('----------------------------------------------------------------------------\n')
    return results
skoulouzis commented 1 year ago

Timeout