update
This commit is contained in:
@@ -1149,17 +1149,21 @@ function generatechat(a::sommelier)
|
||||
pprintln(Dict(responsedict))
|
||||
|
||||
# check if LLM recommend wine before checking inventory
|
||||
isMemEmpty = isempty(a.memory[:shortmem])
|
||||
if occursin("Yes", responsedict[:mentioning_winery]) && isMemEmpty
|
||||
errornote = "Note: You can't recommend wines yet. You must check your inventory before recommending wine to the user."
|
||||
error("You must check your inventory before recommending wine")
|
||||
elseif occursin("(check", responsedict[:chat]) || occursin("*check", responsedict[:chat]) ||
|
||||
occursin("inventory)", responsedict[:chat]) || occursin("inventory*", responsedict[:chat])
|
||||
|
||||
errornote = "Note: You can't recommend wines yet. You must check your inventory before recommending wine to the user."
|
||||
error("You must check your inventory before recommending wine")
|
||||
else
|
||||
errornote = ""
|
||||
ind = 1:length(a.memory[:events])
|
||||
timeline = ""
|
||||
for (i, event) in enumerate(a.memory[:events][ind])
|
||||
if event[:outcome] === nothing
|
||||
timeline *= "$i) $(event[:subject])> $(event[:action_or_dialogue])\n"
|
||||
else
|
||||
timeline *= "$i) $(event[:subject])> $(event[:action_or_dialogue]) $(event[:outcome])\n"
|
||||
end
|
||||
end
|
||||
mentioned_winery = strip.(split(responsedict[:mentioning_winery], ","))
|
||||
for i in mentioned_winery
|
||||
if i != "None" && i != "" && !occursin(i, timeline)
|
||||
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
|
||||
error("Before recommending a wine, ensure it's in your inventory. Check your stock first.")
|
||||
end
|
||||
end
|
||||
|
||||
a.memory[:CHATBOX] = "" # delete content because it no longer used.
|
||||
|
||||
Reference in New Issue
Block a user