This commit is contained in:
youremail@yourdomain.com
2023-12-23 08:17:17 +00:00
parent 78e99457d0
commit ca31fbed33
2 changed files with 48 additions and 28 deletions

View File

@@ -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
<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
</Symbol meaning>
Your earlier work:
$work
<Your earlier work>
$work
</Your earlier work>
<Your job>
Check whether each task of your plan has been completed.
</Your job>
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}
<Example 1>
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.
</Example 1>
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.
</s|>
<|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)