update
This commit is contained in:
29
src/utils.jl
29
src/utils.jl
@@ -4,7 +4,8 @@ export sendReceivePrompt, chunktext, extractStepFromPlan, checkTotalTaskInPlan,
|
||||
detectCharacters, findDetectedCharacter, extract_number, toolNameBeingCalled,
|
||||
isUsePlans, conversationSummary, checkReasonableness, replaceHeaders,
|
||||
addShortMem!, splittext, dictToString, removeHeaders, keepOnlyKeys, experience,
|
||||
messagesToString, messagesToString_nomark, removeTrailingCharacters, shortMemLatestTask
|
||||
messagesToString, messagesToString_nomark, removeTrailingCharacters, shortMemLatestTask,
|
||||
keywordMemoryUpdate!
|
||||
|
||||
using UUIDs, Dates, DataStructures
|
||||
using CommUtils, GeneralUtils
|
||||
@@ -944,7 +945,7 @@ end
|
||||
```jldoctest
|
||||
julia> dict = OrderedDict(
|
||||
"Plan 1:" => "1. Ask about the type of food that will be served at the wedding party.")
|
||||
julia>shortMemLatestTask(dict)
|
||||
julia> shortMemLatestTask(dict)
|
||||
"""
|
||||
function shortMemLatestTask(dict::T) where {T<:AbstractDict}
|
||||
_latest_step = keys(dict)
|
||||
@@ -955,8 +956,32 @@ function shortMemLatestTask(dict::T) where {T<:AbstractDict}
|
||||
end
|
||||
|
||||
|
||||
""" Update a keyword memory
|
||||
|
||||
Arguments:
|
||||
newinfo = a dictionary contain new info
|
||||
keywordmemory = a dictionary contain previous info
|
||||
|
||||
Return:
|
||||
an updated keyword memory
|
||||
|
||||
Example:
|
||||
```jldoctest
|
||||
julia> newinfo = Dict("car type" => "SUV", "engine type" => "electric")
|
||||
julia> keywordmemory = Dict("car type" => "sedan", "car color" => "blue", "financing" => null)
|
||||
julia> keywordMemoryUpdate(keywordmemory, newdict)
|
||||
|
||||
"""
|
||||
function keywordMemoryUpdate!(keywordmemory::AbstractDict, newinfo::AbstractDict)
|
||||
for (k, v) in newinfo
|
||||
k = String(k)
|
||||
if v === nothing && haskey(keywordmemory, k) && keywordmemory[k] !== nothing
|
||||
# skip
|
||||
else
|
||||
keywordmemory[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user