update
This commit is contained in:
31
src/utils.jl
31
src/utils.jl
@@ -3,7 +3,7 @@ module utils
|
||||
export makeSummary, sendReceivePrompt, chunktext, extractStepFromPlan, checkTotalStepInPlan,
|
||||
detectCharacters, findDetectedCharacter, extract_number, toolNameBeingCalled,
|
||||
chooseThinkingMode, conversationSummary, checkReasonableness, addStepNumber,
|
||||
addShortMem!
|
||||
addShortMem!, splittext
|
||||
|
||||
using UUIDs, Dates, DataStructures
|
||||
using CommUtils, GeneralUtils
|
||||
@@ -27,8 +27,7 @@ function makeSummary(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
||||
prompt = replace(prompt, "{input}" => input)
|
||||
result = sendReceivePrompt(a, prompt)
|
||||
result = GeneralUtils.getStringBetweenCharacters(result, "{", "}")
|
||||
println("///// ", result)
|
||||
if result == "Yes"
|
||||
if result == "Yes" # seperate summary part
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
@@ -44,6 +43,9 @@ function makeSummary(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
||||
summary = result
|
||||
end
|
||||
end
|
||||
input_summary = input
|
||||
@show input_summary
|
||||
@show summary
|
||||
|
||||
return summary
|
||||
end
|
||||
@@ -327,7 +329,7 @@ end
|
||||
|
||||
function chooseThinkingMode(a::agentReflex, usermsg::String)
|
||||
thinkingmode = nothing
|
||||
if length(a.thoughtlog) != 0
|
||||
if length(a.memory[:log]) != 0
|
||||
thinkingmode = :continue_thinking
|
||||
else
|
||||
prompt =
|
||||
@@ -531,8 +533,29 @@ end
|
||||
|
||||
|
||||
|
||||
""" Split text using all keywords in a list. Start spliting from rightmost of the text.
|
||||
|
||||
Args:
|
||||
text = a text you want to split
|
||||
list = a list of keywords you want to split
|
||||
|
||||
Return:
|
||||
a leftmost text after split
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> text = "Consider the type of food, occasion and temperature at the serving location."
|
||||
julia> list = ["at", "and"]
|
||||
"Consider the type of food, occasion "
|
||||
```
|
||||
"""
|
||||
function splittext(text, list)
|
||||
newtext = text
|
||||
for i in list
|
||||
newtext = split(newtext, i)[1]
|
||||
end
|
||||
return newtext
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user