Parcourir la source

update route and sql prompt

ling il y a 7 mois
Parent
commit
889552f0c0
3 fichiers modifiés avec 7 ajouts et 3 suppressions
  1. 2 0
      ai_agent.py
  2. 3 1
      systex_app.py
  3. 2 2
      text_to_sql_private.py

+ 2 - 0
ai_agent.py

@@ -240,6 +240,8 @@ def Router():
         You are an expert at routing a user question to a 專業知識 or 自有數據. 
         You are an expert at routing a user question to a 專業知識 or 自有數據. 
         Use company private data for questions about the informations about a company's greenhouse gas emissions data.
         Use company private data for questions about the informations about a company's greenhouse gas emissions data.
         Otherwise, use the 專業知識 for questions on ESG field knowledge or news about ESG. 
         Otherwise, use the 專業知識 for questions on ESG field knowledge or news about ESG. 
+        你需要分辨使用者問題是否在詢問公司的自有數據,例如想了解公司的碳排放源數據等等,如果判斷為是,則使用"自有數據",
+        若使用者的問題是想了解碳盤查或碳管理等等的 ESG 知識和相關新聞,請使用"專業知識"。
         You do not need to be stringent with the keywords in the question related to these topics. 
         You do not need to be stringent with the keywords in the question related to these topics. 
         Give a binary choice '自有數據' or '專業知識' based on the question. 
         Give a binary choice '自有數據' or '專業知識' based on the question. 
         Return the a JSON with a single key 'datasource' and no premable or explanation. 
         Return the a JSON with a single key 'datasource' and no premable or explanation. 

+ 3 - 1
systex_app.py

@@ -44,7 +44,9 @@ def agent(question: str, chat_history: List[ChatHistoryItem] = Body(...)):
     start = time.time()
     start = time.time()
     # TODO rewrite query
     # TODO rewrite query
     # _search_query = get_search_query()
     # _search_query = get_search_query()
-    # chat_history = [(item.q, item.a) for item in chat_history[-5:] if item.a != "" and item.a != "string"]
+    # chat_history = [item for item in chat_history if question != item.q]
+    # chat_history = [(item.q, item.a) for item in chat_history[-5:] if item.a != "" and item.a != "string" ]
+    # print(chat_history)
     # modified_question = _search_query.invoke({"question": question, "chat_history": chat_history})
     # modified_question = _search_query.invoke({"question": question, "chat_history": chat_history})
     
     
     with get_openai_callback() as cb:
     with get_openai_callback() as cb:

+ 2 - 2
text_to_sql_private.py

@@ -316,8 +316,8 @@ def sql_to_nl_chain(llm):
         SQL Result: [(1102.3712,)]
         SQL Result: [(1102.3712,)]
         Answer: 建準廣興廠去年的類別1總排放量是1102.3712
         Answer: 建準廣興廠去年的類別1總排放量是1102.3712
 
 
-        如果你不知道答案或SQL query 出現錯誤請回答:"很抱歉,目前我無法回答您的問題,請將您的詢問發送至 test@systex.com 以便獲得更進一步的幫助,謝謝。"
-        
+        如果你不知道答案或SQL query 出現Error請回答:"很抱歉,目前我無法回答您的問題,請將您的詢問發送至 test@systex.com 以便獲得更進一步的幫助,謝謝。"
+        若 SQL Result 為 0 代表數據為0。
         勿回答無關資訊
         勿回答無關資訊
         <|eot_id|>
         <|eot_id|>