This commit is contained in:
2025-03-14 21:57:27 +07:00
parent 696a77a483
commit 323c232121
2 changed files with 12 additions and 14 deletions

View File

@@ -395,7 +395,6 @@ function evaluator(state::T1, text2textInstructLLM::Function
- Do not generate additional thoughts or actions. - Do not generate additional thoughts or actions.
2) Answer_evaluation: 2) Answer_evaluation:
- Focus only on the matter mentioned in the question and comprehensively analyze how the latest observation's details addresses the question - Focus only on the matter mentioned in the question and comprehensively analyze how the latest observation's details addresses the question
- State your rationale
3) Accepted_as_answer: Decide whether the latest observation's content answers the question. Can be "Yes" or "No" 3) Accepted_as_answer: Decide whether the latest observation's content answers the question. Can be "Yes" or "No"
Bad example (The observation didn't answers the question): Bad example (The observation didn't answers the question):
question: Find cars with 4 wheels. question: Find cars with 4 wheels.
@@ -472,15 +471,14 @@ function evaluator(state::T1, text2textInstructLLM::Function
responsedict = GeneralUtils.textToDict(response, header; responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true) dictKey=dictkey, symbolkey=true)
# check if dict has all required value
trajectoryevaluation_text::AbstractString = responsedict[:trajectory_evaluation]
answerevaluation_text::AbstractString = responsedict[:answer_evaluation]
# responsedict[:score] = replace(responsedict[:score], r"\(.*?\)" => "") # remove (...) if there is any.
responsedict[:score] = responsedict[:score][1] # some time "6\nThe trajectories are incomplete" is generated but I only need the number. responsedict[:score] = responsedict[:score][1] # some time "6\nThe trajectories are incomplete" is generated but I only need the number.
try
responsedict[:score] = parse(Int, responsedict[:score]) # convert string "5" into integer 5 responsedict[:score] = parse(Int, responsedict[:score]) # convert string "5" into integer 5
score::Integer = responsedict[:score] catch
continue
end
accepted_as_answer::AbstractString = responsedict[:accepted_as_answer] accepted_as_answer::AbstractString = responsedict[:accepted_as_answer]
suggestion::AbstractString = responsedict[:suggestion]
if accepted_as_answer ["Yes", "No"] # [PENDING] add errornote into the prompt if accepted_as_answer ["Yes", "No"] # [PENDING] add errornote into the prompt
error("generated accepted_as_answer has wrong format") error("generated accepted_as_answer has wrong format")
@@ -872,9 +870,9 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
earlystop(state) = state[:reward] >= 8 ? true : false earlystop(state) = state[:reward] >= 8 ? true : false
_, _, resultState = LLMMCTS.runMCTS(initialstate, transition, transitionargs; _, _, resultState = LLMMCTS.runMCTS(initialstate, transition, transitionargs;
horizontalSampleExpansionPhase=3, horizontalSampleExpansionPhase=5,
horizontalSampleSimulationPhase=2, horizontalSampleSimulationPhase=2,
maxSimulationDepth=10, maxSimulationDepth=5,
maxiterations=1, maxiterations=1,
explorationweight=1.0, explorationweight=1.0,
earlystop=earlystop, earlystop=earlystop,

View File

@@ -51,9 +51,9 @@ function text2textInstructLLM(prompt::String; maxattempt=3)
) )
) )
response = nothing #[WORKING] receive nothing when LLM container reset response = nothing
for attempts in 1:maxattempt for attempts in 1:maxattempt
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=120, maxattempt=2) _response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=180, maxattempt=2)
response = _response[:response][:text] response = _response[:response][:text]
if response !== nothing if response !== nothing
break break
@@ -157,7 +157,7 @@ sessionId = "555"
# query = Dict(:text=> "How many wines from France do you have that can be paired with lamb?") # query = Dict(:text=> "How many wines from France do you have that can be paired with lamb?")
query = "How many wines are from France?" query = "How many French wines do you have?"
# query = "retailer: Yiem, wine_type: red, sweetness: 1-2, intensity: 4-5, wine price: 20-40" # query = "retailer: Yiem, wine_type: red, sweetness: 1-2, intensity: 4-5, wine price: 20-40"
# query = "wine_type: white, country: United States, sweetness: 1-2, tannin: 3, food to be served with wine: pizza" # query = "wine_type: white, country: United States, sweetness: 1-2, tannin: 3, food to be served with wine: pizza"
# query = "wine_type: white, country: Austria, food to be served with wine: pork" # query = "wine_type: white, country: Austria, food to be served with wine: pork"