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

Function text_to_sql_chat

api/app/api/routes.py:190–212  ·  view source on GitHub ↗

Convert natural language query to SQL

()

Source from the content-addressed store, hash-verified

188# DEPRECATED
189@bp.route('/text_to_sql_chat', methods=['POST'])
190def text_to_sql_chat():
191 """
192 Convert natural language query to SQL
193 """
194 request_body = request.get_json()
195 messages = request_body.get('messages')
196
197 if not messages:
198 error_msg = '`messages` is missing from request body'
199 return make_response(jsonify({"error": error_msg}), 400)
200
201 try:
202 result, sql_query, messages = text_to_sql_chat_with_retry(messages)
203 except Exception as e:
204 capture_exception(e)
205 error_msg = f'Error processing request: {str(e)}'
206 return make_response(jsonify({"error": error_msg}), 500)
207
208 return make_response(jsonify({
209 'result': result,
210 'sql_query': sql_query,
211 'messages': messages
212 }), 200)
213
214@bp.route('/accept_suggestion', methods=['POST'])
215def accept_suggestion():

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected