oracle-llm / sql_templates.py
orachamp1981's picture
Upload 4 files
53d89cd verified
# sql_templates.py
from collections import defaultdict
sql_templates = {
"basic_select": "SELECT column1, column2 FROM table_name;",
"select_where": "SELECT column1 FROM table_name WHERE condition;",
"join_example": "SELECT a.col1, b.col2 FROM table1 a JOIN table2 b ON a.id = b.a_id;",
"group_by": "SELECT dept, COUNT(*) FROM employees GROUP BY dept;",
"having": "SELECT dept, COUNT(*) FROM employees GROUP BY dept HAVING COUNT(*) > 5;",
"insert": "INSERT INTO table_name (col1, col2) VALUES (val1, val2);",
"update": "UPDATE table_name SET col1 = val1 WHERE condition;",
"delete": "DELETE FROM table_name WHERE condition;"
}
sql_keyword_aliases = {
"select": "basic_select",
"where": "select_where",
"join": "join_example",
"group": "group_by",
"group by": "group_by",
"having": "having",
"insert": "insert",
"update": "update",
"delete": "delete"
}
fuzzy_aliases = {
"grouped result": "group_by",
"combine tables": "join_example",
"add new row": "insert",
"modify records": "update",
"remove entry": "delete",
"get rows": "basic_select",
"filter records": "select_where",
"apply condition": "select_where",
"summarize": "group_by",
"count groups": "group_by",
"condition on groups": "having",
"change row": "update",
"erase record": "delete"
}
conflicting_phrases = {
("modify", "new"): "⚠️ You cannot modify a new record. Consider using INSERT instead.",
("update", "new"): "⚠️ You cannot update new data. Did you mean to INSERT?",
("delete", "new"): "⚠️ You cannot delete something that doesn't exist yet.",
}
greeting_templates = {
"hello": "πŸ‘‹ Hello! How can I assist you with SQL or PL/SQL today?",
"hi": "πŸ‘‹ Hi there! Need help with Oracle SQL or PL/SQL?",
"hey": "πŸ‘‹ Hey! Let me know your SQL or PLSQL question.",
"good morning": "πŸŒ… Good morning! What Oracle task can I help with?",
"good afternoon": "🌞 Good afternoon! Ready to write some SQL?",
"good evening": "πŸŒ† Good evening! Need SQL/PLSQL guidance?",
"how are you": "πŸ€– I'm a bot but I'm always ready to help! What do you need?",
"what can you do": "πŸ’‘ I can help you generate Oracle SQL/PLSQL from descriptions, explain syntax, suggest queries, and more.",
}