This commit is contained in:
narawat lamaiin
2025-03-22 09:42:51 +07:00
parent 7d5bc14a09
commit 5a890860a6
3 changed files with 54 additions and 10 deletions

View File

@@ -231,6 +231,9 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
Let's begin!
"""
header = ["Understanding:", "Reasoning:", "Plan:", "Action_name:", "Action_input:"]
dictkey = ["understanding", "reasoning", "plan", "action_name", "action_input"]
chathistory = chatHistoryToText(a.chathistory)
@@ -316,8 +319,16 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
continue
end
header = ["Understanding:", "Reasoning:", "Plan:", "Action_name:", "Action_input:"]
dictkey = ["understanding", "reasoning", "plan", "action_name", "action_input"]
# check whether response has all header
detected_kw = GeneralUtils.detect_keyword(header, response)
if sum(values(detected_kw)) < length(header)
errornote = "\nSQL evaluator() response does not have all header"
continue
elseif sum(values(detected_kw)) > length(header)
errornote = "\nSQL evaluator() response has duplicated header"
continue
end
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
@@ -1229,6 +1240,9 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
Let's begin!
"""
header = ["Understanding:", "Q1:"]
dictkey = ["understanding", "q1"]
context =
if length(a.memory[:shortmem][:available_wine]) != 0
@@ -1339,8 +1353,16 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
error("no answer found in the response ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
end
header = ["Understanding:", "Q1:"]
dictkey = ["understanding", "q1"]
# check whether response has all header
detected_kw = GeneralUtils.detect_keyword(header, response)
if sum(values(detected_kw)) < length(header)
errornote = "\nSQL evaluator() response does not have all header"
continue
elseif sum(values(detected_kw)) > length(header)
errornote = "\nSQL evaluator() response has duplicated header"
continue
end
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
response = "Q1: " * responsedict[:q1]
@@ -1424,6 +1446,17 @@ function generateSituationReport(a, text2textInstructLLM::Function; skiprecent::
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="qwen")
response = text2textInstructLLM(prompt)
# check whether response has all header
detected_kw = GeneralUtils.detect_keyword(header, response)
if sum(values(detected_kw)) < length(header)
errornote = "\nYiemAgent generateSituationReport() response does not have all header"
continue
elseif sum(values(detected_kw)) > length(header)
errornote = "\nYiemAgent generateSituationReport() response has duplicated header"
continue
end
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
@@ -1459,6 +1492,9 @@ function detectWineryName(a, text)
Let's begin!
"""
header = ["Winery_names:"]
dictkey = ["winery_names"]
response = nothing # placeholder for show when error msg show up
@@ -1481,8 +1517,16 @@ function detectWineryName(a, text)
println("\n~~~ detectWineryName() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
pprintln(response)
header = ["Winery_names:"]
dictkey = ["winery_names"]
# check whether response has all header
detected_kw = GeneralUtils.detect_keyword(header, response)
if sum(values(detected_kw)) < length(header)
errornote = "\nSQL evaluator() response does not have all header"
continue
elseif sum(values(detected_kw)) > length(header)
errornote = "\nSQL evaluator() response has duplicated header"
continue
end
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)