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