diff --git a/src/interface.jl b/src/interface.jl index 780d2a1..13e0d35 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -621,7 +621,7 @@ function work(a::agentReflex, usermsg::String) end @show a.attempt @show usermsg - logmsg = "<|im_start|>user:\nStimulus: $usermsg\n<|im_end|>\n" + logmsg = "user: $usermsg\n" a.memory[:shortterm] *= logmsg toolname = nothing @@ -632,12 +632,16 @@ function work(a::agentReflex, usermsg::String) plan = split(respond, "<|im_end|>")[1] plan = split(plan, "Response:")[1] _plan = replace(plan, "Plan:"=>"Plan $(a.attempt):") - logmsg = "<|im_start|>assistant:\n$_plan\n" + logmsg = "assistant: $_plan\n" a.memory[:shortterm] *= logmsg - actorstate, result = actor(a, plan) + actorstate, msgToUser = actor(a, plan) #WORKING if actorstate == "chatbox" break work loop and get back to user + if actorstate == "chatbox" + return msgToUser + end # evaluate + @@ -646,13 +650,14 @@ end """ Actor function. + """ function actor(a::agentReflex, plan::T) where {T<:AbstractString} actorState = nothing @show plan totalsteps = checkTotalStepInPlan(a, plan) - result = nothing + msgToUser = nothing a.step = 0 while true # Actor loop a.step += 1 @@ -680,10 +685,9 @@ function actor(a::agentReflex, plan::T) where {T<:AbstractString} #WORKING if toolname == "chatbox" # chat with user - # a.memory[:shortterm] *= toolinput respond = toolinput _ = addNewMessage(a, "assistant", respond) - result = respond + msgToUser = respond actorState = toolname error("actor done 0") break @@ -694,22 +698,19 @@ function actor(a::agentReflex, plan::T) where {T<:AbstractString} a.memory[:shortterm] *= result end else #TODO finish all steps - - - actorState = "all steps done" - result = "all steps done" error("actor done 2") break end - - - end error("actor done 3") - return actorState, result + return actorState, msgToUser end +""" + Evaluator +""" +# function evaluator(a::agentReflex, plan::T) @@ -718,6 +719,14 @@ end + +# end + + + + + + diff --git a/src/utils.jl b/src/utils.jl index 6bbb155..6c2cdaf 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -423,6 +423,7 @@ function conversationSummary(a::T) where {T<:agent} error("undefied condition role = $role") end end + prompt = replace(prompt, "{conversation}" => conversation) result = sendReceivePrompt(a, prompt) summary = result === nothing ? "nothing" : result