This commit is contained in:
narawat lamaiin
2025-05-04 13:30:08 +07:00
parent 5112701dc2
commit c8f5983620
2 changed files with 44 additions and 51 deletions
+23 -23
View File
@@ -367,17 +367,14 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
- Text information in the database is sometimes stored in lower case. If your search returns empty, try using lower case to search.
You should then respond to the user with:
1) Comprehension:
- State your comprehension about the current situation.
3) Plan: Step-by-step instructions of how to complete the task.
1) Plan: Step-by-step instructions of how to complete the task.
- Focus on improving the code from the last round.
- Do not create any table in the database.
4) Code:
2) Code:
- Write new improved code.
- Do not wrap the code and no comment as it will be executed directly without any modification against the database.
You should only respond in format as described below and nothing more:
Comprehension: ...
Plan:
1) ...
2) ...
@@ -411,9 +408,10 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
try
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
header = ["Comprehension:", "Plan:", "Code:"]
dictkey = ["comprehension", "plan", "code"]
think, response = GeneralUtils.extractthink(response)
header = ["Plan:", "Code:"]
dictkey = ["plan", "code"]
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
@@ -519,9 +517,9 @@ function SQLexecution(executeSQL::Function, sql::T
tablesize = size(df)
row, column = tablesize
if row == 0
error("The resulting table has 0 row. Possible causes: 1) 1) Your search criteria might be overly specific. Consider removing or adjusting highly specific conditions (e.g., exact values, exact phrases, narrow ranges). Start with broader terms and refine your search incrementally. This often resolves empty result. 2) There could be a typo in your search query. 3) You might be searching in the wrong place.")
error("\nThe resulting table has 0 row. Possible causes: 1) Your search criteria might be overly specific. Consider removing or adjusting highly specific conditions (e.g., exact values, exact phrases, narrow ranges). Start with broader terms and refine your search incrementally. This often resolves empty result. 2) When searching for data like wine tasting notes, which often use multiple phrases to describe characteristics, start with a single keyword. If multiple results are returned, you can refine the search further to narrow down the matches. 3) There could be a typo in your search query. 4) You might be searching in the wrong place.")
elseif column > 30
error("SQL execution failed. An unexpected error occurred. Please try again.")
error("\nSQL execution failed. An unexpected error occurred. Please try again.")
end
df1 =
@@ -637,6 +635,7 @@ function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function,
for i in 1:5
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
think, response = GeneralUtils.extractthink(response)
kw = []
# use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list
@@ -839,7 +838,7 @@ function compareState(question::String, highValueStateList::Vector{T},
Question: the question the user is trying to answer
Attempt: the user's attempted actions and their corresponding results
You should then respond to the user with the following:
Comparison: a comparison of all results from all attempts
Comparison: detailed comparison of all results from all attempts from various aspects.
Rationale: a brief explanation of why the selected response is the most accurate and relevant
Selected_response_number: the number the selected response in the list of results (e.g., 1, 2, 3, ...)
You should only respond in format as described below:
@@ -848,10 +847,10 @@ function compareState(question::String, highValueStateList::Vector{T},
Selected_response_number: ...
Here are some examples:
User's question: "How many German wines do you have?"
Attempt 1:
Attempt 1)
Action: SELECT COUNT(*) FROM wines WHERE country = 'Germany'
Result: 100 wines
Attempt 2:
Attempt 2)
Action: SELECT COUNT(*) FROM wines WHERE country = 'Germany' AND type = 'Red'
Result: 50 red wines
Comparison: The second attempt counts only German red wines while the first attempt includes all German wines.
@@ -879,26 +878,26 @@ function compareState(question::String, highValueStateList::Vector{T},
"""
# put potential solutions from potentialSolution into the following form
Attempt 1
action_name:
action_input:
observation:
Attempt 2
action_name:
action_input:
observation:
Attempt 1)
action_name:
action_input:
observation:
Attempt 2)
action_name:`
action_input:
observation:`
...
"""
potentialSolutionStr = ""
for (i, state) in enumerate(potentialSolution)
potentialSolutionStr *= "Attempt $i\n"
potentialSolutionStr *= "Attempt $i)\n"
for k in keys
potentialSolutionStr *= "$k: $(state[k])\n"
println("")
end
end
errornote = ""
errornote = "N/A"
for attempt in 1:10
errorFlag = false
@@ -928,6 +927,7 @@ function compareState(question::String, highValueStateList::Vector{T},
response = replace(response, "**"=>"")
response = replace(response, "***"=>"")
response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
think, response = GeneralUtils.extractthink(response)
# make sure every header is in the response
for i in header