diff --git a/src/interface.jl b/src/interface.jl index e926f52..3e6436f 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -320,7 +320,7 @@ function actor_mistral_openorca(a::agentReflex, taskevaluate="") $toollines Your earlier work: $shorttermMemory - Your task evaluation: + Your progress evaluation of the plan: $taskevaluate $(a.thinkingFormat[:actor]) <|/s|> @@ -375,14 +375,16 @@ function actor_mistral_openorca(a::agentReflex, taskevaluate="") @show iskey_Act = haskey(chunkedtext, "Act $latestTask:") @show iskey_Actinput = haskey(chunkedtext, "Actinput $latestTask:") if iskey_Thought && iskey_Act && iskey_Actinput - if chunkedtext["Thought $latestTask:"] != " " && chunkedtext["Act $latestTask:"] != " " + if chunkedtext["Thought $latestTask:"] != " " && chunkedtext["Act $latestTask:"] != " " && + length(chunkedtext["Actinput $latestTask:"]) > 5 + @show length(chunkedtext["Actinput $latestTask:"]) + @show chunkedtext["Actinput $latestTask:"] break end end end toolname = toolNameBeingCalled(chunkedtext["Act $latestTask:"], a.tools) - chunkedtext["Actinput $latestTask:"] = split(chunkedtext["Actinput $latestTask:"], '\n')[1] toolinput = chunkedtext["Actinput $latestTask:"] # change trailing number to continue a.memory[:shortterm] @@ -600,11 +602,17 @@ function actor(a::agentReflex) actorState = nothing msgToUser = nothing - totaltasks = checkTotalTaskInPlan(a) + + # totaltasks = checkTotalTaskInPlan(a) + while true # Actor loop - # check whether the current task is completed - istaskcomplete, taskevaluation = checkTaskCompletion(a) + # check whether the current task is completed, skip evaluation if memory has only "Plan 1:" + taskevaluation = "" + if length(keys(a.memory[:shortterm])) != 1 + istaskcomplete, taskevaluation = checkTaskCompletion(a) + end + println("") @show taskevaluation latestTask = shortMemLatestTask(a.memory[:shortterm]) +1 println(">>> working") @@ -1041,28 +1049,36 @@ function checkTaskCompletion(a) prompt = """ <|system|> - Symbol meaning: - Plan: a plan - Thought: your thought - Act: the action you took - Actinput: the input to the action - Obs: the result of the action + + Plan: a plan + Thought: your thought + Act: the action you took + Actinput: the input to the action + Obs: the result of the action + - Your earlier work: - $work + + $work + + + Check whether each task of your plan has been completed. + - Your job is to check whether each task of your plan has been completed. - So for instance the following: - Task 2 of the plan: Ask user about their preferred taste of a pizza. - Obs: I love Malvasia. - assistant: I can't find any relevant info that the user tell me their preferred taste in pizza wine according to Obs. Thus, task 2 isn't done yet. {answer: not done} + + Task 1 of the plan: Ask user about their preferred topping of a pizza. + Obs: I love Malvasia. + assistant: After checking all my work's observed results, I can't find any relevant info that the user tell me what is their preferred topping in pizza. Thus, task 1 isn't done yet. + Task 2 of the plan: Ask user if they have any preferred type of car. + Obs: I like a semi truck. + assistant: After checking all my work's observed results, I found that the user like a semi truck. Thus, task 2 is done. + Task 3 of the plan: How much you are looking to spend for a new house? + Obs: 50K THB. + assistant: After checking all my work's observed results, I found that the user have a budget of 50,000 Baht. Thus, task 3 is done. + - Task 5 of the plan: Ask user if they have any preferred type of car. - Obs: I like a semi truck. - assistant: I found relevant info such as the user like a semi truck according to Obs. Thus, task 5 is done. {answer: done} - Let's think step by step. + Let's think step by step. - <|assistant|> I + <|assistant|> After """ response = nothing _response = nothing @@ -1073,7 +1089,7 @@ function checkTaskCompletion(a) break end end - response = "I " * split(_response, "}")[1] * "}" # sometime response have more than 1 {answer: done} + response = "I " * split(_response, "{")[1] # sometime response have more than 1 {answer: done} decision = nothing if occursin("done", response) diff --git a/src/type.jl b/src/type.jl index 36296ef..2ffd7ac 100644 --- a/src/type.jl +++ b/src/type.jl @@ -166,12 +166,16 @@ function agentReflex( """, :actor=> """ - Your task is to use the following format: - Thought: using the plan and task evaluation as a guideline, what to do? (pay attention to correct numeral calculation and commonsense). - Act: the action to take based on your thought, must be one of [{toolnames}] + + 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). + Act: an action to take based on your thought, must be one of [{toolnames}] Actinput: your input to the action you chose (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=> """