update
This commit is contained in:
@@ -56,7 +56,7 @@ end
|
||||
- `state::T2`
|
||||
a game state
|
||||
|
||||
# Return
|
||||
# Return
|
||||
- `thoughtDict::Dict`
|
||||
|
||||
# Example
|
||||
@@ -237,11 +237,11 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
chathistory = chatHistoryToText(a.chathistory)
|
||||
|
||||
# check if winename in shortmem occurred in chathistory. if not, skip decision and imediately use PRESENTBOX
|
||||
if length(a.memory[:shortmem][:available_wine]) != 0
|
||||
if length(a.memory[:shortmem][:found_wine]) != 0
|
||||
# check if wine name mentioned in recentevents, only check first wine name is enough
|
||||
# because agent will recommend every wines it found each time.
|
||||
winenames = []
|
||||
for wine in a.memory[:shortmem][:available_wine]
|
||||
for wine in a.memory[:shortmem][:found_wine]
|
||||
push!(winenames, wine["wine_name"])
|
||||
end
|
||||
|
||||
@@ -257,6 +257,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
4) Provide your personal recommendation based on your understanding of the customer's preferences.",
|
||||
:action_name=> "PRESENTBOX",
|
||||
:action_input=> "")
|
||||
a.memory[:shortmem][:found_wine] = [] # clear because PRESENTBOX command is issued. This is to prevent decisionMaker() keep presenting the same wines
|
||||
return d
|
||||
end
|
||||
end
|
||||
@@ -304,6 +305,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
response = a.func[:text2textInstructLLM](prompt)
|
||||
response = GeneralUtils.remove_french_accents(response)
|
||||
response = replace(response, '*'=>"")
|
||||
response = replace(response, "<|eot_id|>"=>"")
|
||||
|
||||
# check if response contain more than one functions from ["CHATBOX", "CHECKINVENTORY", "ENDCONVERSATION"]
|
||||
count = 0
|
||||
@@ -873,6 +875,8 @@ function think(a::T)::NamedTuple{(:actionname, :result),Tuple{String,String}} wh
|
||||
elseif actionname == "CHECKINVENTORY"
|
||||
if rawresponse !== nothing
|
||||
vd = GeneralUtils.dfToVectorDict(rawresponse)
|
||||
a.memory[:shortmem][:found_wine] = vd # used by decisionMaker() as a short note
|
||||
|
||||
if length(a.memory[:shortmem][:available_wine]) != 0
|
||||
a.memory[:shortmem][:available_wine] = vcat(a.memory[:shortmem][:available_wine], vd)
|
||||
else
|
||||
@@ -1008,6 +1012,7 @@ function generatechat(a::sommelier, thoughtDict)
|
||||
response = replace(response, '*'=>"")
|
||||
response = replace(response, '$' => "USD")
|
||||
response = replace(response, '`' => "")
|
||||
response = replace(response, "<|eot_id|>"=>"")
|
||||
response = GeneralUtils.remove_french_accents(response)
|
||||
responsedict = GeneralUtils.textToDict(response, ["Chat"],
|
||||
rightmarker=":", symbolkey=true, lowercasekey=true)
|
||||
|
||||
@@ -182,6 +182,7 @@ function sommelier(
|
||||
:chatbox=> "",
|
||||
:shortmem=> OrderedDict{Symbol, Any}(
|
||||
:available_wine=> [],
|
||||
:found_wine=> [], # used by decisionMaker(). This is to prevent decisionMaker() keep presenting the same wines
|
||||
),
|
||||
:events=> Vector{Dict{Symbol, Any}}(),
|
||||
:state=> Dict{Symbol, Any}(
|
||||
|
||||
Reference in New Issue
Block a user