This commit is contained in:
2023-12-02 09:26:43 +00:00
parent 6fe84e0cb1
commit 58c7b80c4e
3 changed files with 63 additions and 43 deletions

View File

@@ -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