From dcf57420d16b6a76269fa9bfaa072143b5bf60e6 Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Sun, 5 Jan 2025 13:34:41 +0700 Subject: [PATCH] update --- src/interface.jl | 63 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index bec399e..4c7b3d5 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -131,6 +131,54 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, # """ # end + # systemmsg = + # """ + # You are a helpful assistant that find the data from a database to satisfy the user's query. + # You are also eager to improve your helpfulness. + + # At each round of conversation, the user will give you the current situation: + # User Query: ... + # Example: ... + # Your Q&A: ... + # Your work progress: ... + # Evaluation: Evaluation of the latest action and observation + # Suggestion: ... + + # You must follow the following guidelines: + # - Keep SQL queries focused only on the provided information. + + # You should follow the following guidelines: + # - Do not create any table in the database + # - Column name can be the same in different tables. Refer to column comments to get more details by using TABLEINFO function + # - A junction table can be used to link tables together. Another use case is for filtering data. + # - If you can't find a single table that can be used to answer the user's query, try joining multiple tables to see if you can obtain the answer. + # - If you are unable to find the requested information, kindly inform the user, "The current data in our database does not provide the specific answer to your query". + # - Text information in the database usually stored in lower case. If your search returns empty, try using lower case to search. + + # You should then respond to the user with interleaving Understanding, Reasoning, Plan, Action: + # 1) Understanding: + # - State your understanding about the current situation. + # 2) Reasoning: + # - State your step by step reasoning about the current situation. + # 3) Plan: Given the current circumstances, outline a detailed, step-by-step plan to accomplish the task. Be specific. + # 4) Action_name (Must be aligned with your plan): Can be one of the following functions: + # - TABLEINFO[list_of_table_name], which you can use to get the data type of a table column. "list_of_table_name" is a list of table name you want to get info. e.g. TABLEINFO["table name 1", "table name 2"] + # - GETDATA[SQL], which you can use to get the data from the database. "SQL" is a single SQL command to be executed against the database. + # For more effective text search, it's necessary to use case-insensitivity and the ILIKE operator. + # Do not wrap the SQL as it will be executed against the database directly and SQL must be ended with ';'. + # 5) Action_input: Input to the action + # 6) Observation: Result of the immediately preceding action + + # You should only respond in format as described below: + # Understanding: ... + # Reasoning: ... + # Plan: ... + # Action_name: ... + # Action_input: ... + + # Let's begin! + # """ + systemmsg = """ You are a helpful assistant that find the data from a database to satisfy the user's query. @@ -162,7 +210,6 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, - State your step by step reasoning about the current situation. 3) Plan: Given the current circumstances, outline a detailed, step-by-step plan to accomplish the task. Be specific. 4) Action_name (Must be aligned with your plan): Can be one of the following functions: - - TABLEINFO[list_of_table_name], which you can use to get the data type of a table column. "list_of_table_name" is a list of table name you want to get info. e.g. TABLEINFO["table name 1", "table name 2"] - GETDATA[SQL], which you can use to get the data from the database. "SQL" is a single SQL command to be executed against the database. For more effective text search, it's necessary to use case-insensitivity and the ILIKE operator. Do not wrap the SQL as it will be executed against the database directly and SQL must be ended with ';'. @@ -230,7 +277,7 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, if occursin("NULL", response) errornote = "\nSQL decisionMaker() NULL response is not allowed" println("Attempt $attempt $errornote ", @__FILE__, " ", @__LINE__) - break + continue end header = ["Understanding", "Reasoning", "Plan", "Action_name", "Action_input", "Observation"] @@ -240,7 +287,7 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, if sum(count) > length(header) errornote = "\nSQL decisionMaker() duplicated keywords" println("Attempt $attempt $errornote ", @__FILE__, " ", @__LINE__) - break + continue end # textToDict() search for action_input @@ -263,16 +310,16 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, toollist = ["TABLEINFO", "GETDATA"] if responsedict[:action_name] ∉ toollist - errornote = "\nSQL decisionMaker() didn't use the given functions" + errornote = "\nYou must only use the given functions" println("Attempt $attempt $errornote ", @__FILE__, " ", @__LINE__) - break + continue end for i in toollist if occursin(i, responsedict[:action_input]) errornote = "\nSQL decisionMaker() action_name is in action_input which is not allowed." println("Attempt $attempt $errornote ", @__FILE__, " ", @__LINE__) - break + continue end end @@ -280,7 +327,7 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, if length(JSON3.write(responsedict[i])) == 0 errornote = "\nSQL decisionMaker() $i is empty" println("Attempt $attempt $errornote ", @__FILE__, " ", @__LINE__) - break + continue end end @@ -290,7 +337,7 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function, if length(matchkeys) > 1 errornote = "\nSQL decisionMaker() $i has more than one key" println("Attempt $attempt $errornote ", @__FILE__, " ", @__LINE__) - break + continue end end