diff --git a/src/interface.jl b/src/interface.jl index 6031abd..62623bb 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -266,7 +266,7 @@ function updatePlan(a::agentReflex) end -function actor_mistral_openorca(a::agentReflex, taskevaluate="") +function actor_mistral_openorca(a::agentReflex, taskrecap="") """ general prompt format: @@ -316,13 +316,24 @@ function actor_mistral_openorca(a::agentReflex, taskevaluate="") """ <|system|> $(a.roles[a.role]) - You have access to the following tools: - $toollines - Your earlier work: - $shorttermMemory - Your progress evaluation of the plan: - $taskevaluate - $(a.thinkingFormat[:actor]) + + $toollines + + + $(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). + 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 user one by one question. + <|/s|> <|assistant|> Thought: @@ -336,11 +347,11 @@ function actor_mistral_openorca(a::agentReflex, taskevaluate="") chunkedtext = nothing latestTask = nothing - tempcounter = 0.0 + tempcounter = 0.1 while true # while Thought or Act is empty, run actor again tempcounter += 0.1 @show tempcounter - response = sendReceivePrompt(a, prompt, temperature=tempcounter) + response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=tempcounter) response = splittext(response, ["Obs", "<|im_end|>"]) #WORKING latestTask = shortMemLatestTask(a.memory[:shortterm]) +1 @@ -608,16 +619,16 @@ function actor(a::agentReflex) while true # Actor loop # check whether the current task is completed, skip evaluation if memory has only "Plan 1:" - taskevaluation = "" + taskrecap = "" if length(keys(a.memory[:shortterm])) != 1 - istaskcomplete, taskevaluation = checkTaskCompletion(a) + taskrecap = recap(a) end println("") - @show taskevaluation + @show taskrecap latestTask = shortMemLatestTask(a.memory[:shortterm]) +1 println(">>> working") # work - toolname, toolinput, chunkedtext = actor_mistral_openorca(a, taskevaluation) + toolname, toolinput, chunkedtext = actor_mistral_openorca(a, taskrecap) println("") @show toolname @show toolinput @@ -1098,6 +1109,39 @@ function checkTaskCompletion(a) return decision, response end +function recap(a) + @show a.memory[:shortterm]["Plan 1:"] + # stimulus = a.memory[:shortterm]["user:"] + work = dictToString(a.memory[:shortterm]) + + prompt = + """ + <|system|> + + Plan: a plan + Thought: your thought + Act: the action you took + Actinput: the input to the action + Obs: the result of the action + + + + $work + + + Recap: list all your observed results in detail + + + Let's think step by step. + + <|assistant|> + Recap: + """ + response = sendReceivePrompt(a, prompt, max_tokens=512, temperature=0.0) + response = split(response, "")[1] + + return response +end """ Direct conversation is not an agent, messages does not pass through logic loop but goes directly to LLM. diff --git a/src/type.jl b/src/type.jl index 629567c..2caea59 100644 --- a/src/type.jl +++ b/src/type.jl @@ -168,13 +168,12 @@ function agentReflex( """ Use the following format: - Thought: based on the plan and progress evaluation of the plan, what to do? (pay attention to correct numeral calculation and commonsense). + Thought: based on the plan and the recap of the plan, what to do? (pay attention to correct numeral calculation and commonsense). 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 user one by one question. - Let's think step by step """, :actorOriginal=>