diff --git a/src/interface.jl b/src/interface.jl index a031c3c..b4f8f76 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -349,8 +349,8 @@ function selfAwareness(a::agentReflex) Use the following format strictly: - Info extraction: from the latest observed result, breakdown each info into smaller one and repeat every one of them (PS. check for more details) - Info mapping: based on extracted info, explicitly state what each info could match which keyword memory's key + Info extraction: from the latest observed result, repeat every word relates to wine + Info mapping: based on extracted info, explicitly state what each info could possibly match which keyword memory's key Info matching: using JSON format, what key in my memory matches which info (Donot use nested JSON) @@ -936,7 +936,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing) Use the following format: - Thought: check the user info thoroughly, if there is something you don't know (as indicates by null) you must address it first. Otherwise, you must think about what is the immediate next step to do according to the plan (PS. 1. pay attention to correct numeral calculation and commonsense 2. you must assume nothing) + Thought: check the user info thoroughly to see if there is something you don't know (as indicates by null), you must address it the immediate next step. Otherwise, you must think about what is the immediate next step to do according to the plan (PS. 1. pay attention to correct numeral calculation and commonsense 2. you must assume nothing 3. do not ask for confirmation) Act: based on your thought what action to choose?, must be one of [{toolnames}]. Actinput: your input to the action using JSON format (pay attention to the tool's input) Obs: observed result of the action diff --git a/src/utils.jl b/src/utils.jl index 4de4386..856c8fc 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -974,13 +974,21 @@ end """ function keywordMemoryUpdate!(keywordmemory::AbstractDict, newinfo::AbstractDict) + for (k, v) in newinfo k = String(k) - if v === nothing && haskey(keywordmemory, k) && keywordmemory[k] !== nothing - # skip + + # some time input keyword is different than dict's key thus it skip update + # e.x. input key "tannin level" => "low to medium" + # dict key "wine tannin level" => "low to medium" + similar_k = checkSimilarKey(keywordmemory, k) + k = similar_k === nothing ? k : similar_k + + if v === nothing && haskey(keywordmemory, similar_k) && keywordmemory[similar_k] !== nothing + # do not write value nothing if the key already has value else if haskey(keywordmemory, k) - println("before k $k v $(keywordmemory[k])") #BUG this function write null to a non-empty key + println("before k $k v $(keywordmemory[k])") end println("write k $k v $v") keywordmemory[k] = v @@ -991,7 +999,16 @@ function keywordMemoryUpdate!(keywordmemory::AbstractDict, newinfo::AbstractDict end - +function checkSimilarKey(dict::AbstractDict, key::AbstractString) + similar_k = nothing + for (k, v) in dict + if occursin(key, String(k)) + similar_k = k + break + end + end + return similar_k +end