From a5e22184f8f3bd7ce11cc541191843e4a51fb794 Mon Sep 17 00:00:00 2001 From: "youremail@yourdomain.com" Date: Sun, 24 Dec 2023 12:23:55 +0000 Subject: [PATCH] update --- src/interface.jl | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index f550cbd..b97245c 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -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="") $(a.memory[:shortterm]["Plan 1:"]) - + $taskrecap - + 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. <|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, " 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]) Plan: a plan Thought: your thought @@ -1169,7 +1181,7 @@ function recap(a) $work - 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. Let's think step by step.