This commit is contained in:
youremail@yourdomain.com
2023-12-24 12:23:55 +00:00
parent cc50da91e8
commit a5e22184f8

View File

@@ -315,6 +315,13 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
# $conversation
# """
start = "Thought"
aware = ""
if taskrecap != ""
start = "Aware"
aware = "Aware: check recap against the plan about current situation"
end
prompt =
"""
<|system|>
@@ -325,21 +332,20 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
<Your plan>
$(a.memory[:shortterm]["Plan 1:"])
</Your plan>
<Your earlier work's recap in JSON format>
<Your earlier work's recap>
$taskrecap
</Your earlier work's recap in JSON format>
</Your earlier work's recap>
<Your job>
Use the following format:
Thought: based on the plan and the recap of the plan, what to do? (pay attention to correct numeral calculation and commonsense).
$aware
Thought: based on the plan and the recap of the plan, what to do? (pay attention to correct numeral calculation, commonsense. ask the user one by one question.)
Act: an action to take based on your thought, must be one of [{toolnames}]
Actinput: your input to the action based on your thought (pay attention to the tool's input)
Obs: observed result of the action
P.S.1 ask the user one by one question.
</Your job>
</s>
<|assistant|>
Thought:
$start:
"""
prompt = replace(prompt, "{toolnames}" => toolnames)
@@ -350,32 +356,37 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
chunkedtext = nothing
latestTask = nothing
tempcounter = 0.1
tempcounter = 0.2
while true # while Thought or Act is empty, run actor again
tempcounter += 0.1
# tempcounter += 0.1
@show tempcounter
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=tempcounter)
response = splittext(response, ["Obs", "<|im_end|>"])
#WORKING
latestTask = shortMemLatestTask(a.memory[:shortterm]) +1
if !occursin("Thought", response)
if start == "Thought"
response = "Thought $latestTask: " * response
else
response = "Aware $latestTask: " * response
end
headerToDetect = ["Question:", "Plan:", "Thought:",
headerToDetect = ["Question:", "Plan:", "Aware:", "Thought:",
"Act:", "Actinput:", "Obs:", "...",
"Answer:", "Conclusion:", "Summary:"]
# replace headers with headers with correct attempt and task number
response = replaceHeaders(response, headerToDetect, latestTask)
response = split(response, "\n\n ")[1]
response = split(response, "<|")[1]
response = split(response, "</")[1]
headers = detectCharacters(response, headerToDetect)
println("")
@show actor_response = response
headerToDetect = ["Plan $(a.attempt):",
"Aware $latestTask:",
"Thought $latestTask:",
"Act $latestTask:",
"Actinput $latestTask:",
@@ -391,8 +402,6 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
if iskey_Thought && iskey_Act && iskey_Actinput
if chunkedtext["Thought $latestTask:"] != " " && chunkedtext["Act $latestTask:"] != " " &&
length(chunkedtext["Actinput $latestTask:"]) > 5
@show length(chunkedtext["Actinput $latestTask:"])
@show chunkedtext["Actinput $latestTask:"]
break
end
end
@@ -402,10 +411,11 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
toolinput = chunkedtext["Actinput $latestTask:"]
# change trailing number to continue a.memory[:shortterm]
headerToDetect = ["Question:", "Plan:", "Thought:",
headerToDetect = ["Question:", "Plan:", "Aware:", "Thought:",
"Act:", "Actinput:", "Obs:", "...",
"Answer:", "Conclusion:", "Summary:"]
response = replaceHeaders(response, headerToDetect, latestTask)
@show actor_response = response
headerToDetect = ["Plan $(a.attempt):",
"Thought $latestTask:",
"Act $latestTask:",
@@ -413,7 +423,8 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
"Obs $latestTask:",
"Check $latestTask:",]
headers = detectCharacters(response, headerToDetect)
chunkedtext = chunktext(response, headers)
chunkedtext = chunktext(response, headers)
chunkedtext = delete!(chunkedtext, "Aware $latestTask")
return toolname, toolinput, chunkedtext
end
@@ -1157,6 +1168,7 @@ function recap(a)
prompt =
"""
<|system|>
$(a.roles[a.role])
<Symbol meaning>
Plan: a plan
Thought: your thought
@@ -1169,7 +1181,7 @@ function recap(a)
$work
</Your earlier work>
<Your job>
Extract info: extract info in details from ALL Actinput and corresponding observed result into JSON format
Extract info: extract all info in details from your earlier work.
</Your job>
Let's think step by step.