Closed skoulouzis closed 1 year ago
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
Timeout
UI design
API usage example: