CoolFace
Apppublic

Gonalb/multi_agentic_sql_generator

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
validation.cpython-313.pyc23 linesDownload Raw Back to __pycache__
12g��g����SSKrSrg)�Nc��URSS5nU(dSSS0S.$SUS3n[RRR	SS	US3./SS9nUR4S
RRR5nURS5(a0URSS5RSS5R5nUSS0S.$)z&Validates and optimizes the SQL query.�
generated_sql��errorzNo SQL query to validate.)�
optimized_sql�validation_resultz�5    Validate and optimize the following SQL query. Check for:6    1. Syntax correctness7    2. Proper table and column references8    3. Performance optimization opportunities9 10    ```sql11    a�12    ```13 14    **Rules:**15    - DO NOT create or suggest any indexes.16    - DO NOT include any CREATE INDEX, ALTER TABLE, or similar DDL statements.17    - Focus only on query structure optimization without modifying the database schema.18    - Optimize filters and joins.19    - Use appropriate WHERE clauses and join conditions.20    - Output only the SQL query without markdown formatting.21    - The table name must be the full ecommerceaie5.table_name format.22    zgpt-4o-mini�user)�role�contentg)�model�messages�temperaturerz```sqlz```�validT)�get�openai�chat�completions�create�choices�messager�strip�23startswith�replace)�state�	sql_query�prompt�response�optimized_querys     �I/home/usuario/Escritorio/Multi-Agentic-SQL-Generator/agents/validation.py�!query_validation_and_optimizationr s����	�	�/�2�.�I��!#�7�D_�:`�a�a���K���F�&�{�{�&�&�-�-��!�f�5�6��.��H��&�&�q�)�1�1�9�9�?�?�A�O��!�!�(�+�+�)�1�1�(�B�?�G�G��r�R�X�X�Z��(�%�t�_���)rr �r!r�<module>r#s
��
�(r!