This commit is contained in:
2025-07-23 18:31:38 +07:00
parent 21416f4b13
commit a4227ec165
2 changed files with 30 additions and 27 deletions

View File

@@ -694,14 +694,15 @@ function evaluator(state::T1, thoughtDict, text2textInstructLLM::Function, llmFo
response = replace(response, "***"=>"") response = replace(response, "***"=>"")
# check whether response has all header # check whether response has all header
detected_kw = GeneralUtils.detect_keyword(header, response) detected_kw = GeneralUtils.detectKeywordVariation(header, response)
if 0 values(detected_kw) missingkeys = [k for (k, v) in detected_kw if v === nothing]
errornote = "Your previous attempt does not have all answer points" if !isempty(missingkeys)
println("\nERROR SQLLLM evaluator() Attempt $attempt/$maxattempt. $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())") errornote = "$missingkeys are missing from your previous response"
println("\nERROR SQLLLM extractContent_dataframe() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
elseif sum(values(detected_kw)) > length(header) elseif sum([length(i) for i in values(detected_kw)]) > length(header)
errornote = "Your previous attempt has duplicated answer point" errornote = "\nYour previous attempt has duplicated points according to the required response format"
println("\nERROR SQLLLM evaluator() Attempt $attempt/$maxattempt. $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR SQLLLM extractContent_dataframe() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
end end

View File

@@ -637,15 +637,17 @@ function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function,
response = GeneralUtils.deFormatLLMtext(response, llmFormatName) response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
think, response = GeneralUtils.extractthink(response) think, response = GeneralUtils.extractthink(response)
kw = [] # check whether response has all header
# use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list detected_kw = GeneralUtils.detectKeywordVariation(header, response)
for keyword in header missingkeys = [k for (k, v) in detected_kw if v === nothing]
detected = GeneralUtils.detect_keyword(keyword, response) if !isempty(missingkeys)
push!(kw, detected) errornote = "$missingkeys are missing from your previous response"
end println("\nERROR SQLLLM extractContent_dataframe() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
if nothing kw continue
println("Some keywords are missing, Required keywords=$header, Response keywords=$kw ", @__FILE__, ":", @__LINE__, " $(Dates.now())") elseif sum([length(i) for i in values(detected_kw)]) > length(header)
continue # try again next loop errornote = "\nYour previous attempt has duplicated points according to the required response format"
println("\nERROR SQLLLM extractContent_dataframe() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue
end end
responsedict = GeneralUtils.textToDict(response, header; responsedict = GeneralUtils.textToDict(response, header;
@@ -929,17 +931,17 @@ function compareState(question::String, highValueStateList::Vector{T},
response = GeneralUtils.deFormatLLMtext(response, llmFormatName) response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
think, response = GeneralUtils.extractthink(response) think, response = GeneralUtils.extractthink(response)
# make sure every header is in the response # check whether response has all header
for i in header detected_kw = GeneralUtils.detectKeywordVariation(header, response)
detected = GeneralUtils.detect_keyword(i, response) missingkeys = [k for (k, v) in detected_kw if v === nothing]
if detected === nothing if !isempty(missingkeys)
errornote = "Your previous attempt didn't provide $i" errornote = "$missingkeys are missing from your previous response"
errorFlag = true println("\nERROR SQLLLM extractContent_dataframe() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
end continue
end elseif sum([length(i) for i in values(detected_kw)]) > length(header)
if errorFlag errornote = "\nYour previous attempt has duplicated points according to the required response format"
println("\nERROR SQLLLM compareState() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR SQLLLM extractContent_dataframe() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue # skip to the next iteration continue
end end
responsedict = GeneralUtils.textToDict(response, header; dictKey=dictkey, symbolkey=true) responsedict = GeneralUtils.textToDict(response, header; dictKey=dictkey, symbolkey=true)