Convert natural language query to SQL
()
| 188 | # DEPRECATED |
| 189 | @bp.route('/text_to_sql_chat', methods=['POST']) |
| 190 | def 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']) |
| 215 | def accept_suggestion(): |
nothing calls this directly
no test coverage detected