update
This commit is contained in:
@@ -132,17 +132,39 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
1:totalevents
|
||||
end
|
||||
|
||||
timeline = ""
|
||||
recentevents = ""
|
||||
for (i, event) in enumerate(a.memory[:events][ind])
|
||||
if event[:outcome] === nothing
|
||||
timeline *= "$i) $(event[:subject])> $(event[:actioninput])\n"
|
||||
recentevents *= "$i) $(event[:subject])> $(event[:actioninput])\n"
|
||||
else
|
||||
timeline *= "$i) $(event[:subject])> $(event[:actioninput]) $(event[:outcome])\n"
|
||||
recentevents *= "$i) $(event[:subject])> $(event[:actioninput]) $(event[:outcome])\n"
|
||||
end
|
||||
end
|
||||
|
||||
#[TESTING] recap as caching
|
||||
# query similar result from vectorDB
|
||||
similarDecision = a.func[:similarSommelierDecision](timeline)
|
||||
recapkeys = keys(a.memory[:recap])
|
||||
_recapkeys_vec = [i for i in recapkeys]
|
||||
|
||||
# select recent keys
|
||||
_recentRecapKeys =
|
||||
if length(a.memory[:recap]) <= 3 # 1st message is a user's hello msg
|
||||
_recapkeys_vec
|
||||
elseif length(a.memory[:recap]) > 3
|
||||
l = length(a.memory[:recap])
|
||||
_recapkeys_vec[l-2:l]
|
||||
end
|
||||
|
||||
# get recent recap
|
||||
_recentrecap = OrderedDict()
|
||||
for (k, v) in a.memory[:recap]
|
||||
if k ∈ _recentRecapKeys
|
||||
_recentrecap[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
recentrecap = GeneralUtils.dictToString_noKey(_recentrecap)
|
||||
similarDecision = a.func[:similarSommelierDecision](recentrecap)
|
||||
|
||||
if similarDecision !== nothing
|
||||
responsedict = similarDecision
|
||||
@@ -213,7 +235,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
|
||||
# check if winename in shortmem occurred in chathistory. if not, skip decision and imediately use PRESENTBOX
|
||||
if haskey(a.memory[:shortmem], :available_wine)
|
||||
# check if wine name mentioned in timeline, 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.
|
||||
df = a.memory[:shortmem][:available_wine]
|
||||
winenames = df[:, :wine_name]
|
||||
@@ -242,7 +264,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
|
||||
usermsg =
|
||||
"""
|
||||
Your recent events: $timeline
|
||||
Your recent events: $recentevents
|
||||
Your Q&A: $QandA)
|
||||
$errornote
|
||||
"""
|
||||
@@ -345,15 +367,6 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
|
||||
delete!(responsedict, :mentioned_winery)
|
||||
|
||||
# #CHANGE cache decision dict into vectorDB, this should be after new message is added to a.memory[:events]
|
||||
# println("\n~~~ Do you want to cache decision dict? (y/n)")
|
||||
# user_answer = readline()
|
||||
# if user_answer == "y"
|
||||
# timeline = timeline
|
||||
# decisiondict = responsedict
|
||||
# a.func[:insertSommelierDecision](timeline, decisiondict)
|
||||
# end
|
||||
|
||||
return responsedict
|
||||
end
|
||||
error("DecisionMaker failed to generate a thought ", response)
|
||||
@@ -1223,16 +1236,21 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
||||
errornote = ""
|
||||
response = nothing # store for show when error msg show up
|
||||
|
||||
#[WORKING]
|
||||
recap =
|
||||
if a.memory[:recap] === nothing
|
||||
if length(a.memory[:recap]) <= recent
|
||||
"None"
|
||||
else
|
||||
if length(a.memory[:events]) > recent
|
||||
GeneralUtils.dictToString(a.memory[:recap][1:end-recent])
|
||||
else
|
||||
"None"
|
||||
recapkeys = keys(a.memory[:recap])
|
||||
recapkeys_vec = [i for i in recapkeys]
|
||||
recapkeys_vec = recapkeys_vec[1:end-recent]
|
||||
tempmem = OrderedDict()
|
||||
for (k, v) in a.memory[:recap]
|
||||
if k ∈ recapkeys_vec
|
||||
tempmem[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
GeneralUtils.dictToString(tempmem)
|
||||
end
|
||||
|
||||
for attempt in 1:10
|
||||
@@ -1373,7 +1391,7 @@ end
|
||||
# end
|
||||
|
||||
function generateSituationReport(a, text2textInstructLLM::Function; skiprecent::Integer=0
|
||||
)::Dict
|
||||
)::OrderedDict
|
||||
|
||||
systemmsg =
|
||||
"""
|
||||
@@ -1404,16 +1422,7 @@ function generateSituationReport(a, text2textInstructLLM::Function; skiprecent::
|
||||
return nothing
|
||||
end
|
||||
|
||||
# events = deepcopy(a.memory[:events][1:end-skiprecent])
|
||||
|
||||
# timeline = ""
|
||||
# for (i, event) in enumerate(events)
|
||||
# if event[:outcome] === nothing
|
||||
# timeline *= "$i) $(event[:subject])> $(event[:actioninput])\n"
|
||||
# else
|
||||
# timeline *= "$i) $(event[:subject])> $(event[:actioninput]) $(event[:outcome])\n"
|
||||
# end
|
||||
# end
|
||||
events = a.memory[:events][1:end-skiprecent]
|
||||
|
||||
timeline = createTimeline(a.memory[:events]; skiprecent=skiprecent)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user