update
This commit is contained in:
39
src/utils.jl
39
src/utils.jl
@@ -3,7 +3,7 @@ module utils
|
||||
export makeSummary, sendReceivePrompt, chunktext, extractStepFromPlan, checkTotalStepInPlan,
|
||||
detectCharacters, findDetectedCharacter, extract_number, toolNameBeingCalled,
|
||||
chooseThinkingMode, conversationSummary, checkReasonableness, replaceHeaders,
|
||||
addShortMem!, splittext
|
||||
addShortMem!, splittext, shortMemoryToString
|
||||
|
||||
using UUIDs, Dates, DataStructures
|
||||
using CommUtils, GeneralUtils
|
||||
@@ -619,16 +619,43 @@ function replaceHeaders(text::T, headers, step::Int) where {T<:AbstractString}
|
||||
end
|
||||
|
||||
|
||||
""" Convert short term memory into 1 continous string.
|
||||
|
||||
Args:
|
||||
shortMemory = a short memory of a ChatAgent's agent
|
||||
skiplist = a list of keys in memory you want to skip
|
||||
|
||||
Return:
|
||||
a short term memory in 1 countinuous string
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> shortMemory = OrderedDict(
|
||||
"Thought" => "I like it.",
|
||||
"Act" => "chatbox",
|
||||
"ActInput" => "I get this one.",
|
||||
)
|
||||
|
||||
julia> headers = ["user:"]
|
||||
julia> shortMemoryToString(shortMemory, headers)
|
||||
```
|
||||
"""
|
||||
function shortMemoryToString(shortMemory::OrderedDict,
|
||||
skiplist::Union{Array{String}, Array{Symbol}})
|
||||
s = ""
|
||||
for (k, v) in shortMemory
|
||||
if k ∉ skiplist
|
||||
s1 = "$k $v"
|
||||
s *= s1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ensure a newline seperate each sentences
|
||||
if s[end] != "\n"
|
||||
s *= "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user