update
This commit is contained in:
@@ -1272,7 +1272,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
|||||||
|
|
||||||
Let's begin!
|
Let's begin!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
context =
|
context =
|
||||||
if length(a.memory[:shortmem][:available_wine]) != 0
|
if length(a.memory[:shortmem][:available_wine]) != 0
|
||||||
"Available wines you've found in your inventory so far: $(availableWineToText(a.memory[:shortmem][:available_wine]))"
|
"Available wines you've found in your inventory so far: $(availableWineToText(a.memory[:shortmem][:available_wine]))"
|
||||||
@@ -1340,6 +1340,32 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
|||||||
|
|
||||||
try
|
try
|
||||||
response = text2textInstructLLM(prompt)
|
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:
|
# sometime LLM generate more than 1 Understanding:
|
||||||
understanding_number = count("Understanding:", response)
|
understanding_number = count("Understanding:", response)
|
||||||
|
|||||||
Reference in New Issue
Block a user