Browse Source

add new column '範疇'

ling 4 months ago
parent
commit
f32ae83c55
2 changed files with 23 additions and 2 deletions
  1. 1 0
      post_processing_sqlparse.py
  2. 22 2
      text_to_sql_private.py

+ 1 - 0
post_processing_sqlparse.py

@@ -60,6 +60,7 @@ def parse_sql_where(sql):
     column_dict = {
         "排放源": None,
         "類別": None,
+        "範疇": None,
         "類別項目": None,
         "項目": None,
         

+ 22 - 2
text_to_sql_private.py

@@ -109,7 +109,17 @@ def get_examples():
                         AND "年度" = EXTRACT(YEAR FROM CURRENT_DATE)-1;""",
         },
         {
-            "input": "建準北海廠去年的類別1總排放量",
+            "input": "廣興廠2023綠電使用量",
+            "query": """SELECT SUM("用電度數(kwh)") AS "綠電使用量"
+                        FROM "用電度數"
+                        WHERE "項目" like '%綠電%'
+                        AND "事業名稱" like '%建準%'
+                        AND "據點" = '昆山廣興廠'
+                        AND "盤查標準" = 'GHG'
+                        AND "年度" = 2023;""",
+        },
+        {
+            "input": "北海廠去年的類別1總排放量",
             "query": """SELECT SUM("排放量(公噸CO2e)") AS "類別1總排放量"
                         FROM "建準碳排放清冊數據new"
                         WHERE "事業名稱" like '%建準%'
@@ -119,7 +129,7 @@ def get_examples():
                         AND "年度" = EXTRACT(YEAR FROM CURRENT_DATE)-1;""",
         },
         {
-            "input": "建準廣興廠去年的直接排放總排放量是多少?",
+            "input": "廣興廠去年的直接排放總排放量是多少?",
             "query": """SELECT SUM("排放量(公噸CO2e)") AS "直接排放總排放量"
                         FROM "建準碳排放清冊數據new"
                         WHERE "事業名稱" like '%建準%'
@@ -178,6 +188,15 @@ def get_examples():
                         AND "盤查標準" = 'GHG'
                         AND "年度" = EXTRACT(YEAR FROM CURRENT_DATE)-2;""",
         },
+        {
+            "input": "建準去年範疇三排放量",
+            "query": """SELECT SUM("排放量(公噸CO2e)") AS "範疇三排放量"
+                        FROM "建準碳排放清冊數據new"
+                        WHERE "事業名稱" like '%建準%'
+                        AND "範疇" = '範疇三'
+                        AND "盤查標準" = 'GHG'
+                        AND "年度" = EXTRACT(YEAR FROM CURRENT_DATE)-1;""",
+        },
 
 
 
@@ -195,6 +214,7 @@ def table_description():
         "- `事業名稱`: 公司名稱"
         "- `據點`: 建準廠房據點 include '高雄總部及運通廠', '台北辦事處', '昆山廣興廠', '北海建準廠', '北海立準廠', '菲律賓建準廠', 'Inc', 'SAS', 'India'"
         "- `國家`: 據點所在國家"
+        "- `範疇`: 碳盤查中把溫室氣體排放源分成三大範疇"
         "- `類別`: 溫室氣體的排放類別,包含以下選項:\n"
         "   \t*類別1-直接排放:\n"
         "   \t*類別2-能源間接排放\n"