update
This commit is contained in:
+37
-24
@@ -318,9 +318,10 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
continue
|
||||
end
|
||||
|
||||
responsedict = GeneralUtils.textToDict(response,
|
||||
["Understanding", "Reasoning", "Plan", "Action_name", "Action_input"],
|
||||
rightmarker=":", symbolkey=true, lowercasekey=true)
|
||||
header = ["Understanding:", "Reasoning:", "Plan:", "Action_name:", "Action_input:"]
|
||||
dictkey = ["understanding", "reasoning", "plan", "action_name", "action_input"]
|
||||
responsedict = GeneralUtils.textToDict(response, header;
|
||||
dictKey=dictkey, symbolkey=true)
|
||||
|
||||
if responsedict[:action_name] ∉ ["CHATBOX", "CHECKINVENTORY", "ENDCONVERSATION"]
|
||||
errornote = "You must use the given functions"
|
||||
@@ -999,6 +1000,9 @@ function generatechat(a::sommelier, thoughtDict)
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
header = ["Chat:"]
|
||||
dictkey = ["chat"]
|
||||
|
||||
# a.memory[:shortmem][:available_wine] is a vector of dictionary
|
||||
context =
|
||||
if length(a.memory[:shortmem][:available_wine]) != 0
|
||||
@@ -1054,22 +1058,27 @@ function generatechat(a::sommelier, thoughtDict)
|
||||
response = replace(response, '`' => "")
|
||||
response = replace(response, "<|eot_id|>"=>"")
|
||||
response = GeneralUtils.remove_french_accents(response)
|
||||
responsedict = GeneralUtils.textToDict(response, ["Chat"],
|
||||
rightmarker=":", symbolkey=true, lowercasekey=true)
|
||||
|
||||
for i ∈ [:chat]
|
||||
if length(JSON3.write(responsedict[i])) == 0
|
||||
error("$i is empty ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
|
||||
end
|
||||
# check whether response has all header
|
||||
detected_kw = GeneralUtils.detect_keyword(header, response)
|
||||
if sum(values(detected_kw)) < length(header)
|
||||
errornote = "\nSQL decisionMaker() response does not have all header"
|
||||
continue
|
||||
elseif sum(values(detected_kw)) > length(header)
|
||||
errornote = "\nSQL decisionMaker() response has duplicated header"
|
||||
continue
|
||||
end
|
||||
|
||||
# check if there are more than 1 key per categories
|
||||
for i ∈ [:chat]
|
||||
matchkeys = GeneralUtils.findMatchingDictKey(responsedict, i)
|
||||
if length(matchkeys) > 1
|
||||
error("generatechat has more than one key per categories")
|
||||
end
|
||||
end
|
||||
responsedict = GeneralUtils.textToDict(response, header;
|
||||
dictKey=dictkey, symbolkey=true)
|
||||
|
||||
# # check if there are more than 1 key per categories
|
||||
# for i ∈ Symbol.(dictkey)
|
||||
# matchkeys = GeneralUtils.findMatchingDictKey(responsedict, i)
|
||||
# if length(matchkeys) > 1
|
||||
# error("generatechat has more than one key per categories")
|
||||
# end
|
||||
# end
|
||||
|
||||
# check if Context: is in chat
|
||||
if occursin("Context:", responsedict[:chat])
|
||||
@@ -1385,9 +1394,10 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
||||
error("no answer found in the response ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
|
||||
end
|
||||
|
||||
responsedict = GeneralUtils.textToDict(response,
|
||||
["Understanding", "Q1"],
|
||||
rightmarker=":", symbolkey=true, lowercasekey=true)
|
||||
header = ["Understanding:", "Q1:"]
|
||||
dictkey = ["understanding", "q1"]
|
||||
responsedict = GeneralUtils.textToDict(response, header;
|
||||
dictKey=dictkey, symbolkey=true)
|
||||
response = "Q1: " * responsedict[:q1]
|
||||
println("\n~~~ generatequestion ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
|
||||
pprintln(response)
|
||||
@@ -1469,9 +1479,10 @@ function generateSituationReport(a, text2textInstructLLM::Function; skiprecent::
|
||||
"""
|
||||
|
||||
response = text2textInstructLLM(prompt)
|
||||
eventheader = ["Event_$i" for i in eachindex(a.memory[:events])]
|
||||
responsedict = GeneralUtils.textToDict(response, eventheader,
|
||||
rightmarker=":", symbolkey=true)
|
||||
header = ["Event_$i:" for i in eachindex(a.memory[:events])]
|
||||
dictkey = lowercase.(["Event_$i" for i in eachindex(a.memory[:events])])
|
||||
responsedict = GeneralUtils.textToDict(response, header;
|
||||
dictKey=dictkey, symbolkey=true)
|
||||
|
||||
println("\n~~~ generateSituationReport() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
|
||||
pprintln(response)
|
||||
@@ -1530,8 +1541,10 @@ function detectWineryName(a, text)
|
||||
println("\n~~~ detectWineryName() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
|
||||
pprintln(response)
|
||||
|
||||
responsedict = GeneralUtils.textToDict(response, ["winery_names"],
|
||||
rightmarker=":", symbolkey=true, lowercasekey=true)
|
||||
header = ["Winery_names:"]
|
||||
dictkey = ["winery_names"]
|
||||
responsedict = GeneralUtils.textToDict(response, header;
|
||||
dictKey=dictkey, symbolkey=true)
|
||||
|
||||
result = responsedict[:winery_names]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user