File size: 2,386 Bytes
53d89cd
 
79367ca
 
62fcaa3
 
 
 
 
 
 
 
 
 
79367ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9762962
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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.",
}