| 98 | |
| 99 | @failsoft |
| 100 | def log_input_classification(app_name, input_text, metadata, parent_id, session_id=None): |
| 101 | if not EVENTS_ENGINE: |
| 102 | return None |
| 103 | |
| 104 | params = { |
| 105 | "app_name": app_name, |
| 106 | "input_text": input_text, |
| 107 | "metadata": json.dumps(metadata), |
| 108 | "parent_id": parent_id, |
| 109 | "session_id": session_id |
| 110 | } |
| 111 | |
| 112 | insert_query = text(""" |
| 113 | INSERT INTO input_classifications (app_name, input_text, metadata, parent_id, session_id) |
| 114 | VALUES (:app_name, :input_text, :metadata, :parent_id, :session_id) |
| 115 | returning id |
| 116 | """) |
| 117 | |
| 118 | with EVENTS_ENGINE.connect() as conn: |
| 119 | # get the ID back |
| 120 | result = conn.execute(insert_query, params) |
| 121 | conn.commit() |
| 122 | row = result.fetchone() |
| 123 | generation_id = row[0] |
| 124 | |
| 125 | return str(generation_id) |
| 126 | |
| 127 | @failsoft |
| 128 | def update_input_classification(id: str, ran_sql: bool, rows_returned: int, generated_sql: str): |