update
This commit is contained in:
@@ -1340,6 +1340,32 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
||||
|
||||
try
|
||||
response = text2textInstructLLM(prompt)
|
||||
# make sure generatequestion() don't have wine name that is not from retailer inventory
|
||||
# check whether an agent recommend wines before checking inventory or recommend wines
|
||||
# outside its inventory
|
||||
# ask LLM whether there are any winery mentioned in the response
|
||||
mentioned_winery = detectWineryName(a, response)
|
||||
if mentioned_winery != "None"
|
||||
mentioned_winery = String.(strip.(split(mentioned_winery, ",")))
|
||||
|
||||
# check whether the wine is in event
|
||||
isWineInEvent = false
|
||||
for winename in mentioned_winery
|
||||
for event in a.memory[:events]
|
||||
if event[:outcome] !== nothing && occursin(winename, event[:outcome])
|
||||
isWineInEvent = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# if wine is mentioned but not in timeline or shortmem,
|
||||
# then the agent is not supposed to recommend the wine
|
||||
if isWineInEvent == false
|
||||
errornote = "Previously, You mentioned wines that is not in your inventory which is not allowed."
|
||||
error("Previously, You mentioned wines that is not in your inventory which is not allowed.")
|
||||
end
|
||||
end
|
||||
|
||||
# sometime LLM generate more than 1 Understanding:
|
||||
understanding_number = count("Understanding:", response)
|
||||
|
||||
Reference in New Issue
Block a user