update
This commit is contained in:
23
src/utils.jl
23
src/utils.jl
@@ -230,8 +230,23 @@ function extractStepFromPlan(a::agent, plan::T, step::Int) where {T<:AbstractStr
|
||||
end
|
||||
|
||||
function checkTotalStepInPlan(a::agent)
|
||||
p = a.memory[:shortterm]["Plan 1:"]
|
||||
plan = "Plan 1: $p"
|
||||
headers = []
|
||||
|
||||
for (k, v) in agent.memory[:shortterm]
|
||||
push!(headers, k)
|
||||
end
|
||||
|
||||
# Plan will have number e.g. Plan 3: so I need a way to detect latest Plan
|
||||
header = nothing
|
||||
for i in reverse(headers)
|
||||
if occursin("Plan", i)
|
||||
header = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
p = a.memory[:shortterm][header]
|
||||
plan = "Plan: $p"
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
@@ -586,7 +601,7 @@ julia> headers = ["Thought", "Act"]
|
||||
|
||||
```
|
||||
"""
|
||||
function replaceHeaders(text::T, headers, attempt::Int, step::Int, substep::Int) where {T<:AbstractString}
|
||||
function replaceHeaders(text::T, headers, step::Int) where {T<:AbstractString}
|
||||
newtext = text
|
||||
for i in headers
|
||||
header = i[:char][1:end-1]
|
||||
@@ -594,7 +609,7 @@ function replaceHeaders(text::T, headers, attempt::Int, step::Int, substep::Int)
|
||||
startind = findfirst(i[:char], newtext)[1]
|
||||
stopind = findnext(":", newtext, startind+1)[end]
|
||||
word = newtext[startind: stopind]
|
||||
newtext = replace(newtext, word=> "$header $attempt-$step-$substep:")
|
||||
newtext = replace(newtext, word=> "$header $step:")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user