From db6c9c5f2be1c0071476e7c0aac828c5066813ea Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Fri, 7 Mar 2025 13:34:15 +0700 Subject: [PATCH] update --- src/interface.jl | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/interface.jl b/src/interface.jl index 7e3ae51..15d73b8 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -1272,7 +1272,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St Let's begin! """ - + 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]))" @@ -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)