diff --git a/src/interface.jl b/src/interface.jl
index 9b41889..f986d70 100755
--- a/src/interface.jl
+++ b/src/interface.jl
@@ -185,8 +185,8 @@ function planner_mistral_openorca(a::agentReflex)
"""
<|system|>
$(a.roles[a.role])
- The required info you need for wine recommendation:
- - type of food: ask the user
+ Required info you need for wine recommendation:
+ - food that will be served with wine: ask the user
- occasion: ask the user
- type of wine (Rose, White, Red and Sparkling): ask the user
- user's personal taste of wine characteristic: ask the user
@@ -314,12 +314,14 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
"""
#BUG BIG output from winestock cause recap() to fail.
#BUG2 LLM repeat winestock search without recommending wine
+ toolslist = []
toolnames = ""
toollines = ""
for (toolname, v) in a.tools
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
toollines *= toolline
toolnames *= "$toolname, "
+ push!(toolslist, toolname)
end
# shorttermMemory = dictToString(a.memory[:shortterm], skiplist=["user:"])
@@ -336,11 +338,11 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
start = "Thought"
aware = ""
- if taskrecap != ""
+ if length(a.memory[:shortterm]) > 2 # must have User:, Plan:, Thought:, Act:, Actinput:
start = "Self-awareness"
# aware = "Self-awareness: based on the recap, assess your progress against the plan then identify areas where you need to address."
# aware = "Self-awareness: based on the recap and the plan, state your current understanding of the matter in details then identify areas where you need to address."
- aware = "Self-awareness: based on earlier conversation with the user, check your progress against the plan then assess the current situation to identify tasks that you need to address."
+ aware = "Self-awareness: based on earlier conversation with the user, check your progress against the plan then assess the current situation to identify areas where you already achieved and areas where you need to addresss. (focus on your actions and their results)"
end
winestockResult = ""
@@ -366,8 +368,8 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
Use the following format:
$aware
- Thought: based on the plan and self-awareness, What to do? (P.S.1 pay attention to correct numeral calculation and commonsense.)
- Act: an action to take, must be one of [{toolnames}]
+ Thought: based on self-awareness and the plan, What to do? (pay attention to correct numeral calculation and commonsense and do one thing at a time.)
+ Act: an action you intend 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
@@ -428,8 +430,16 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
@show iskey_Thought = haskey(chunkedtext, "Thought $latestTask:")
@show iskey_Act = haskey(chunkedtext, "Act $latestTask:")
@show iskey_Actinput = haskey(chunkedtext, "Actinput $latestTask:")
+ istoolnameValid = false
+ for i in toolslist
+ if occursin(i, chunkedtext["Act $latestTask:"])
+ istoolnameValid = true
+ break
+ end
+ end
+
if iskey_Thought && iskey_Act && iskey_Actinput
- if chunkedtext["Thought $latestTask:"] != " " && chunkedtext["Act $latestTask:"] != " " &&
+ if length(chunkedtext["Thought $latestTask:"]) > 5 && istoolnameValid &&
length(chunkedtext["Actinput $latestTask:"]) > 5
break
end
@@ -705,6 +715,7 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
@show isuseplan
if isuseplan # use plan before responding
+ a.memory[:shortterm]["User:"] = usermsg
workstate, response = work(a)
end
@@ -714,6 +725,7 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
else
response = chat_mistral_openorca(a)
response = split(response, "\n\n")[1]
+ response = split(response, "\n\n")[1]
end
response = removeTrailingCharacters(response)
@@ -731,7 +743,7 @@ function work(a::agentReflex)
response = nothing
# user answering LLM -> Obs
- if length(a.memory[:shortterm]) != 0
+ if length(a.memory[:shortterm]) > 1
latestTask = shortMemLatestTask(a.memory[:shortterm])
if haskey(a.memory[:shortterm], "Act $latestTask:")
if occursin("chatbox", a.memory[:shortterm]["Act $latestTask:"])
@@ -766,7 +778,7 @@ function work(a::agentReflex)
response = msgToUser
workstate = actorstate
break
- elseif actorstate == "all tasks done"
+ elseif actorstate == "formulateFinalResponse"
println("all tasks done")
response = formulateUserresponse(a)
@@ -859,16 +871,16 @@ function actor(a::agentReflex)
while true # Actor loop
# check whether the current task is completed, skip evaluation if memory has only "Plan 1:"
- taskrecap = ""
- if length(keys(a.memory[:shortterm])) != 1
- taskrecap = recap(a)
- end
- println("")
- @show taskrecap
+ # taskrecap = ""
+ # if length(keys(a.memory[:shortterm])) != 1
+ # taskrecap = recap(a)
+ # end
+ # println("")
+ # @show taskrecap
latestTask = shortMemLatestTask(a.memory[:shortterm]) +1
println(">>> working")
# work
- toolname, toolinput, chunkedtext = actor_mistral_openorca(a, taskrecap)
+ toolname, toolinput, chunkedtext = actor_mistral_openorca(a)
println("")
@show toolname
@show toolinput
@@ -881,8 +893,10 @@ function actor(a::agentReflex)
msgToUser = toolinput
actorState = toolname
break
- elseif toolname == "noaction"
+ elseif toolname == "recommendwine" #WORKING
println(">>> already done")
+ actorState = "formulateFinalResponse"
+ break
else # function call
f = a.tools[toolname][:func]
toolresult = f(a, toolinput)
@@ -936,7 +950,7 @@ function writeEvaluationGuideline(a::agentReflex)
wikisearch: Useful for when you need to search an encyclopedia Input is keywords and not a question.
Your work:
- $(a.memory[:shortterm]["Objective:"])
+ $(a.memory[:shortterm]["User:"])
Your job are:
1. Write an evaluation guideline for your work in order to be able to evaluate your response.
diff --git a/src/utils.jl b/src/utils.jl
index e4f626c..56988d2 100644
--- a/src/utils.jl
+++ b/src/utils.jl
@@ -350,12 +350,18 @@ function isUsePlans(a::agentReflex)
You have access to the following tools:
$toollines
- Your task is to decide whether you need think thoroughly in order to respond to the user according to your conversation with the user and tools you have.
+
+ Your job is to decide whether you need think thoroughly in order to respond to the user according to your conversation with the user and tools you have.
+
+
So for instance the following:
user: Hello!. How are you?
assistant: {No}, the user is greeting me, I could respond right away.
+
+
user: "I want a bottle of wine."
assistant: {Yes}, I need to think thoroughly about the user stimulus.
+
$conversation
<|assistant|>