This commit is contained in:
2023-12-18 14:17:21 +00:00
parent c3500e2780
commit d90ff8d3fc
3 changed files with 26 additions and 16 deletions

View File

@@ -175,6 +175,9 @@ function planner_mistral_openorca(a::agentReflex)
toollines *= toolline
end
end
# skip objective and plan because LLM is going to generate new plan
shorttermMemory = dictToString(a.memory[:shortterm], skiplist=["Objective:", "Plan 0:"])
assistant_plan_prompt =
"""
@@ -192,12 +195,15 @@ function planner_mistral_openorca(a::agentReflex)
You have access to the following tools:
$toollines
Your work:
$shorttermMemory
Use the following format:
Objective: the objective you intend to do
Aware: ask yourself what info you don't have?
Plan: first you should always think about the objective, the info you have, the info you don't have and thoroughly then extract and devise a complete, step by step plan (pay attention to correct numeral calculation and commonsense).
Aware: according to your work and your conversation with the user, ask yourself what info you have and what info you doesn't have?
Plan: first you should always think about the objective, the info you have, the info you doesn't have thoroughly then extract and devise a complete, step by step plan (pay attention to correct numeral calculation and commonsense).
P.S.1 each step of the plan should be a single action.
P.S.2 ask the user all you need to know and then search your inventory.
P.S.2 ask the user if you don't have info.
<|im_end|>
$conversation
@@ -329,6 +335,9 @@ function actor_mistral_openorca(a::agentReflex)
prompt = replace(prompt, "{toolnames}" => toolnames)
prompt = replace(prompt, "{step}" => a.step)
println("")
@show prompt_actor = prompt
response = nothing
chunkedtext = nothing
@@ -349,12 +358,12 @@ function actor_mistral_openorca(a::agentReflex)
# replace headers with headers with correct attempt and step number
response = replaceHeaders(response, headerToDetect, a.step)
response = split(response, "\n\n ")[1]
headers = detectCharacters(response, headerToDetect)
println("")
response_actor = response
@show response_actor
@show response_actor = response
headerToDetect = ["Plan $(a.attempt):",
"Thought $(a.step):",
@@ -364,7 +373,6 @@ function actor_mistral_openorca(a::agentReflex)
"Check $(a.step):",]
headers = detectCharacters(response, headerToDetect)
chunkedtext = chunktext(response, headers)
@show chunkedtext
# assuming length more than 10 character means LLM has valid thinking
if length(chunkedtext["Thought $(a.step):"]) > 10
@@ -383,21 +391,21 @@ function actor_mistral_openorca(a::agentReflex)
headerToDetect = ["Question:", "Plan:", "Thought:",
"Act:", "Actinput:", "Obs:", "...",
"Answer:", "Conclusion:", "Summary:"]
response = replaceHeaders(response, headerToDetect, latest_step+1)
nextstep = latest_step+1 # next step in short term memory
response = replaceHeaders(response, headerToDetect, nextstep)
headerToDetect = ["Plan $(a.attempt):",
"Thought $latest_step:",
"Act $latest_step:",
"Actinput $latest_step:",
"Obs $latest_step:",
"Check $latest_step:",]
"Thought $nextstep:",
"Act $nextstep:",
"Actinput $nextstep:",
"Obs $nextstep:",
"Check $nextstep:",]
headers = detectCharacters(response, headerToDetect)
chunkedtext = chunktext(response, headers)
# add to memory
addShortMem!(a.memory[:shortterm], chunkedtext)
a.memory[:log] = addShortMem!(a.memory[:log], chunkedtext)
@show a.memory[:shortterm]
error(1)
return toolname, toolinput
end
@@ -476,6 +484,7 @@ function work(a::agentReflex)
workstate = nothing
response = nothing
#BUG there is no Obs 2:
# user answering LLM -> Obs
if haskey(a.memory[:shortterm], "Act $(a.step):")
if occursin("chatbox", a.memory[:shortterm]["Act $(a.step):"])
@@ -509,6 +518,7 @@ function work(a::agentReflex)
a.memory[:shortterm]["Objective:"] = objective
a.memory[:shortterm]["Plan $(a.attempt):"] = plan
a.memory[:log]["Plan $(a.attempt):"] = plan
a.step = 0 # reset because new plan is created
println("")
@show objective