This commit is contained in:
2026-06-29 20:55:52 +07:00
parent bc81033924
commit c085a445e2
8 changed files with 137 additions and 71 deletions
+7 -7
View File
@@ -3,7 +3,7 @@ module llmfunction
export listAllTable_json, listAllTable_str, tableinfo, getdata, finalAnswerBox,
getTableNameFromSQL, extractContent_dataframe, SQLexecution, compareState
using HTTP, JSON3, URIs, Random, PrettyPrinting, UUIDs, LibPQ, Tables, DataFrames, CSV,
using HTTP, JSON, URIs, Random, PrettyPrinting, UUIDs, LibPQ, Tables, DataFrames, CSV,
DataStructures, StatsBase, Dates
using GeneralUtils, LLMMCTS
using ..util
@@ -189,7 +189,7 @@ function tableinfo(executeSQL::Function, tablenames::T
end
end
if !isempty(notExistingTable)
result = "Error, the following tables does not exist in the database: $(JSON3.write(notExistingTable))"
result = "Error, the following tables does not exist in the database: $(JSON.json(notExistingTable))"
return (result=result,)
end
@@ -297,7 +297,7 @@ context = args["context"]
result["thought"], result["code"]
else
nothing, state["question"]
end
end
# make new state
newNodeKey = GeneralUtils.uuid4snakecase()
@@ -319,7 +319,7 @@ newstate["code"] = sql
newstate["errorexplain"] = thought
newstate["errormsg"] = errormsg
newstate["reward"] = reward
newstate["isterminal"] = isterminal
newstate["isterminal"] = isterminal
if response !== nothing
extracted = extractContent_dataframe(response, context, text2textInstructLLM)
newstate["response"] = extracted
@@ -779,7 +779,7 @@ function getTableNameFromSQL(sql::T, text2textInstructLLM::Function,
response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=false)
response = copy(JSON3.read(responsedict["table_name"]))
response = copy(JSON.parse(responsedict["table_name"]))
return response
catch e
@@ -876,7 +876,7 @@ potentialSolution = []
d[v] = thoughtHistory[latestKeys[i]]
end
push!(potentialSolution, d)
end
end
"""
# put potential solutions from potentialSolution into the following form
@@ -948,7 +948,7 @@ potentialSolution = []
responsedict["selected_response_number"] = responsedict["selected_response_number"][1] # some time "6\nThe trajectories are incomplete" is generated but I only need the number.
try
responsedict["selected_response_number"] = parse(Int, responsedict["selected_response_number"]) # convert string "5" into integer 5
responsedict["selected_response_number"] = parse(Int, responsedict["selected_response_number"]) # convert string "5" into integer 5
catch
errornote = "In your previous attempt, Selected_response_number was not a number. It must be a number."
println("\nERROR SQLLLM compareState() Attempt $attempt. $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")