diff --git a/src/interface.jl b/src/interface.jl
index f986d70..f7b9fb1 100755
--- a/src/interface.jl
+++ b/src/interface.jl
@@ -223,7 +223,7 @@ function updatePlan(a::agentReflex)
toollines = ""
for (toolname, v) in a.tools
- if toolname ∉ ["chatbox"]
+ if toolname ∉ ["askbox"]
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
toollines *= toolline
end
@@ -338,11 +338,13 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
start = "Thought"
aware = ""
+ thought = "Thought: you should always think about what to do according to the plan (pay attention to correct numeral calculation and commonsense and do one thing at a time.)"
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 areas where you already achieved and areas where you need to addresss. (focus on your actions and their results)"
+ aware = "Self-awareness: based on earlier conversation with the user, check your progress against the plan then assess the current situation to identify not complete tasks. (focus on your actions and their results)"
+ thought = "Thought: you should always think about what to do according to self-awareness (1. let's think a single step. 2. pay attention to correct numeral calculation and commonsense.)"
end
winestockResult = ""
@@ -368,8 +370,8 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
Use the following format:
$aware
- 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}]
+ $thought
+ Act: an action you intend, 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
@@ -430,15 +432,15 @@ 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
+ istoolnameValid = false
+ for i in toolslist
+ if occursin(i, chunkedtext["Act $latestTask:"])
+ istoolnameValid = true
+ break
+ end
+ end
if length(chunkedtext["Thought $latestTask:"]) > 5 && istoolnameValid &&
length(chunkedtext["Actinput $latestTask:"]) > 5
break
@@ -465,6 +467,7 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
headers = detectCharacters(response, headerToDetect)
chunkedtext = chunktext(response, headers)
chunkedtext = delete!(chunkedtext, "Self-awareness $latestTask")
+ chunkedtext["Actinput $latestTask:"] = split(chunkedtext["Actinput $latestTask:"], "\n\n")[1]
return toolname, toolinput, chunkedtext
end
@@ -475,7 +478,7 @@ end
# for (k, v) in a.memory[:shortterm]
# count = 0
# for i in getonlykeys
-# if occursin(i, k)
+# if occursin(i, k)
# count += 1
# end
# end
@@ -719,8 +722,8 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
workstate, response = work(a)
end
- # if LLM using chatbox, use returning msg form chatbox as conversation response
- if workstate == "chatbox" || workstate == "formulatedUserResponse"
+ # if LLM using askbox, use returning msg form askbox as conversation response
+ if workstate == "askbox" || workstate == "formulatedUserResponse"
#TODO paraphrase msg so that it is human friendlier word.
else
response = chat_mistral_openorca(a)
@@ -735,7 +738,7 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
end
"""
- Continuously run llm functions except when llm is getting Answer: or chatbox.
+ Continuously run llm functions except when llm is getting Answer: or askbox.
There are many work() depend on thinking mode.
"""
function work(a::agentReflex)
@@ -746,7 +749,7 @@ function work(a::agentReflex)
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:"])
+ if occursin("askbox", a.memory[:shortterm]["Act $latestTask:"])
a.memory[:shortterm]["Obs $latestTask:"] = a.messages[end][:content]
end
end
@@ -774,7 +777,7 @@ function work(a::agentReflex)
# enter actor loop
actorstate, msgToUser = actor(a)
- if actorstate == "chatbox"
+ if actorstate == "askbox"
response = msgToUser
workstate = actorstate
break
@@ -856,7 +859,7 @@ end
actorState = "all tasks done" inidicates that all task in plan were done.
msgToUser = nothing.
case 2) if actor needs to talk to user for more context
- actorState = "chatbox"
+ actorState = "askbox"
msgToUser = "message from assistant to user"
"""
@@ -889,11 +892,11 @@ function actor(a::agentReflex)
addShortMem!(a.memory[:shortterm], chunkedtext)
println("")
- if toolname == "chatbox" # chat with user
+ if toolname == "askbox" # chat with user
msgToUser = toolinput
actorState = toolname
break
- elseif toolname == "recommendwine" #WORKING
+ elseif toolname == "finalanswer" #WORKING
println(">>> already done")
actorState = "formulateFinalResponse"
break
@@ -946,7 +949,7 @@ function writeEvaluationGuideline(a::agentReflex)
"""
<|im_start|>system
You have access to the following tools:
- chatbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
+ askbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
wikisearch: Useful for when you need to search an encyclopedia Input is keywords and not a question.
Your work:
@@ -998,20 +1001,26 @@ function grading(a, guideline::T, text::T) where {T<:AbstractString}
"""
<|im_start|>system
You have access to the following tools:
- chatbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
+ askbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
wikisearch: Useful for when you need to search an encyclopedia Input is keywords and not a question.
+
$guideline
+
+
+ $text
+
- Your response: $text
-
- You job are:
+
1. Evaluate your response using the evaluation guideline and an example response.
- 2. Give yourself a score out of 10 for your response.
-
- Use the following format to answer:
- {Evaluation} Score {}/10.
+ 2. Give yourself a score out of 9 for your response.
+
+
+ Evaluate: The response does not directly address user needs. It does not include price into account and other user mentioned factors. Score: 6/9.
+
<|im_end|>
+
+ Evaluate:
"""
println("")
prompt_grading = prompt
@@ -1022,7 +1031,7 @@ function grading(a, guideline::T, text::T) where {T<:AbstractString}
println("")
response_grading = response
@show response_grading
-
+ response = split(response, "\n\n")[1]
_score = split(response[end-5:end], "/")[1]
_score = split(_score, " ")[end]
score = parse(Int, _score)
@@ -1062,7 +1071,7 @@ function analyze(a)
"""
<|im_start|>system
You have access to the following tools:
- chatbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
+ askbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
wikisearch: Useful for when you need to search an encyclopedia Input is keywords and not a question.
Your work:
@@ -1121,7 +1130,7 @@ function selfReflext(a, analysis::T) where {T<:AbstractString}
"""
<|im_start|>system
You have access to the following tools:
- chatbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
+ askbox: Useful for when you need to ask a customer for more context. Input should be a conversation to customer.
wikisearch: Useful for when you need to search an encyclopedia Input is keywords and not a question.
Your report: