This commit is contained in:
2025-03-18 07:34:51 +07:00
parent 14c881741e
commit 7c9ceb06f8
4 changed files with 388 additions and 37 deletions

View File

@@ -10,6 +10,8 @@ using ..util, ..llmfunction
""" Think and choose action.
# Arguments
@@ -871,15 +873,24 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
earlystop(state) = state[:reward] >= 8 ? true : false
root, _, resultState = LLMMCTS.runMCTS(initialstate, transition, transitionargs;
horizontalSampleExpansionPhase=5,
horizontalSampleSimulationPhase=2,
maxSimulationDepth=5,
maxiterations=1,
explorationweight=1.0,
earlystop=earlystop,
saveSimulatedNode=true,
multithread=true)
root, _, resultState, highValueState =
LLMMCTS.runMCTS(initialstate, transition, transitionargs;
horizontalSampleExpansionPhase=5,
horizontalSampleSimulationPhase=2,
maxSimulationDepth=5,
maxiterations=1,
explorationweight=1.0,
earlystop=earlystop,
saveSimulatedNode=true,
multithread=true)
#[WORKING] compare all high value state answer then select the best one
if length(highValueState) > 0
open("/appfolder/app/highValueState.json", "w") do io
JSON3.pretty(io, highValueState)
end
resultState = compareState(query, highValueState)
end
latestKey, latestInd = GeneralUtils.findHighestIndexKey(resultState[:thoughtHistory], "observation")
action_input = Symbol("action_input_$latestInd") # latest sql
sql = resultState[:thoughtHistory][action_input]
@@ -1119,8 +1130,6 @@ end