diff --git a/src/interface.jl b/src/interface.jl index d111210..07a999e 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -239,7 +239,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent} - If you don't already know, find out the occasion for which the user is buying wine. - If you don't already know, find out the characteristics of wine the user is looking for, such as tannin, sweetness, intensity, acidity. - If you don't already know, find out what food will be served with wine. - - If you haven't already, present the wines you found to the user. + - If you haven't already, introduce the wines you found in the database to the user first. You should then respond to the user with interleaving Thought, Plan, Action: 1) thought: @@ -249,7 +249,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent} - CHATBOX which you can use to generate conversation in order to communicate with the user. The input is your intention for the talk. Be specific. - CHECKINVENTORY which you can use to check info about wine in your inventory. The input is a search term in verbal English. Good query example: black car, a stereo, 200 mile range, electric motor. - - PRESENTBOX which you can use to introduce wines to users for the first time. It is more effective than the CHATBOX function for presenting wines. The input is the names of wines to present. + - PRESENTBOX which you can use to introduce wines you just found in the database to the user. It is better than the CHATBOX function for presenting wines. The input is the names of wines to introduce. - ENDCONVERSATION which you can use when you want to finish the conversation with the user. The input is "NA". 4) action_input: input details of the action 5) mentioning_wine: Are you mentioning specific wine name to the user? Can be "Yes" or "No" @@ -270,7 +270,12 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent} else "" end - # chathistory = vectorOfDictToText(a.chathistory) + + # get only the latest 3 conversation + x = length(a.chathistory) < 3 ? length(a.chathistory) : 3 + x = x - 1 + chathistory = vectorOfDictToText(a.chathistory[end-x:end]) + errornote = "" response = nothing # placeholder for show when error msg show up @@ -278,6 +283,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent} usermsg = """ Recap: $(a.memory[:recap]) + Your recent conversation with the user: $chathistory Your Q&A: $(a.memory[:QandA]) $errornote """ @@ -1111,9 +1117,7 @@ function think(a::T)::NamedTuple{(:actionname, :result), Tuple{String, String}} if actionname == "CHATBOX" a.memory[:CHATBOX] = result elseif actionname == "CHECKINVENTORY" - x = "I have searched the inventory, this is what I found: $result" - x = result - push!(a.memory[:shortmem], Dict(Symbol(actionname)=> x)) + push!(a.memory[:shortmem], Dict(Symbol(actionname)=> result)) elseif actionname == "PRESENTBOX" # tell the generatechat() a.memory[:CHATBOX] = result elseif actionname == "ENDCONVERSATION" @@ -1304,7 +1308,7 @@ function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::F """ context = - if length(memory[:shortmem]) > 0 + if length(memory[:shortmem]) > 0 #[WORKING] add with number order 1), 2) vectorOfDictToText(memory[:shortmem], withkey=false) else "" diff --git a/src/llmfunction.jl b/src/llmfunction.jl index 3c27bfa..878dfc1 100644 --- a/src/llmfunction.jl +++ b/src/llmfunction.jl @@ -451,6 +451,8 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2< delete!(responsedict, :flavors) delete!(responsedict, :aromas) delete!(responsedict, :price) + delete!(responsedict, :occasion) + delete!(responsedict, :food_to_be_paired_with_wine) # remove (some text) for (k, v) in responsedict diff --git a/test/runtest.jl b/test/runtest.jl index 2291d04..bbcbe69 100644 --- a/test/runtest.jl +++ b/test/runtest.jl @@ -88,8 +88,8 @@ end main() """ - I'm joining a graduation party this evening. I have unlimited budget and I'm ok with wines in all price range. I want a bottle of full bodied, dry white wine. - Well, it is a small casual party with close friends and no food serving. + I'm joining a graduation party this evening. I have unlimited budget and I'm ok with wines in all price range. I want a bottle of full bodied, dry white wine from the U.S. + Well, the party is small casual with close friends and no food serving. I'm open to suggestion since I have no specific idea about wine. """