update
This commit is contained in:
@@ -232,6 +232,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)
|
||||
|
||||
# check if winename in shortmem occurred in chathistory. if not, skip decision and imediately use PRESENTBOX
|
||||
@@ -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)
|
||||
|
||||
@@ -1230,6 +1241,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
|
||||
"Available wines you've found in your inventory so far: $(availableWineToText(a.memory[:shortmem][:available_wine]))"
|
||||
@@ -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)
|
||||
|
||||
@@ -1460,6 +1493,9 @@ function detectWineryName(a, text)
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
header = ["Winery_names:"]
|
||||
dictkey = ["winery_names"]
|
||||
|
||||
response = nothing # placeholder for show when error msg show up
|
||||
|
||||
for attempt in 1:10
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"description": "agent role"
|
||||
},
|
||||
"organization": {
|
||||
"value": "yiem_hq",
|
||||
"value": "yiem_branch_1",
|
||||
"description": "organization name"
|
||||
},
|
||||
"externalservice": {
|
||||
|
||||
@@ -36,7 +36,7 @@ function executeSQLVectorDB(sql)
|
||||
return result
|
||||
end
|
||||
|
||||
function text2textInstructLLM(prompt::String; maxattempt=3)
|
||||
function text2textInstructLLM(prompt::String; maxattempt=2)
|
||||
msgMeta = GeneralUtils.generate_msgMeta(
|
||||
config[:externalservice][:loadbalancer][:mqtttopic];
|
||||
msgPurpose="inference",
|
||||
@@ -60,7 +60,7 @@ function text2textInstructLLM(prompt::String; maxattempt=3)
|
||||
|
||||
response = nothing
|
||||
for attempts in 1:maxattempt
|
||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=300, maxattempt=maxattempt)
|
||||
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg; timeout=180, maxattempt=maxattempt)
|
||||
payload = _response[:response]
|
||||
if _response[:success] && payload[:text] !== nothing
|
||||
response = _response[:response][:text]
|
||||
@@ -234,7 +234,7 @@ a = YiemAgent.sommelier(
|
||||
)
|
||||
|
||||
while true
|
||||
println("your respond: ")
|
||||
print("your respond: ")
|
||||
user_answer = readline()
|
||||
response = YiemAgent.conversation(a, Dict(:text=> user_answer))
|
||||
println("\n$response")
|
||||
|
||||
Reference in New Issue
Block a user