MCPcopy Create free account
hub / github.com/caesarHQ/textSQL / get_census_data_get

Function get_census_data_get

api/app/api/chat_gpt_plugin.py:7–41  ·  view source on GitHub ↗

Get census data based on the question

()

Source from the content-addressed store, hash-verified

5
6@plugin.route('get_census_data', methods=['GET'])
7def get_census_data_get():
8 """
9 Get census data based on the question
10 """
11
12 question = request.args.get('question')
13 if not question:
14 return jsonify({
15 "error": "question is missing from the request args"
16 })
17
18 raw_table_json = requests.post('https://text-sql-be.onrender.com/api/get_tables', json={"natural_language_query": question})
19
20 print('raw table: ', raw_table_json.json())
21
22 newJson = {
23 **raw_table_json.json(),
24 "natural_language_query": question,
25 }
26
27 print('new json: ', newJson)
28
29 final_res = requests.post('https://text-sql-be.onrender.com/api/text_to_sql', json=newJson)
30
31 print('final res: ', final_res.json())
32
33 parsed = final_res.json()
34
35 resultsData = parsed['result']['results']
36 sqlData = parsed['sql_query']
37
38 return jsonify({
39 "answer": resultsData,
40 "sql_query": sqlData,
41 })
42
43
44plugin_config = Blueprint('plugin_config', __name__)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected