kaxil commented on code in PR #70137:
URL: https://github.com/apache/airflow/pull/70137#discussion_r3616357391


##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm_sql.py:
##########
@@ -177,10 +177,13 @@ def _strip_llm_output(raw: str) -> str:
         text = raw.strip()
         if text.startswith("```"):
             lines = text.split("\n")
-            # Remove opening fence (```sql, ```, etc.) and closing fence
             if len(lines) >= 2:
+                # Remove opening fence (```sql, ```, etc.) and closing fence
                 end = -1 if lines[-1].strip().startswith("```") else len(lines)
                 text = "\n".join(lines[1:end]).strip()
+            elif text.endswith("```") and len(text) > 6:
+                # Whole fenced block on one line, e.g. "```SELECT 1```" -> 
"SELECT 1"
+                text = text[3:-3].strip()

Review Comment:
   Does this want to handle a single-line fence that still has a language tag, 
like ````sql SELECT 1````? `text[3:-3]` leaves `sql SELECT 1`, which then fails 
validation. The multi-line path strips the tag by dropping the first line, but 
there's no line to drop here. Fine to skip if you haven't seen models collapse 
a tagged fence onto one line -- just flagging since it's the same defensive 
path you're extending.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to