update
This commit is contained in:
@@ -351,12 +351,13 @@ function actor_mistral_openorca(a::agentReflex)
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
{role}
|
||||
{context}
|
||||
{tools}
|
||||
{role}
|
||||
{thinkingFormat}
|
||||
<|im_end|>
|
||||
{context}
|
||||
{shorttermMemory}
|
||||
Thought $(a.step):
|
||||
"""
|
||||
|
||||
prompt = replace(prompt, "{role}" => a.roles[a.role])
|
||||
@@ -392,7 +393,7 @@ function actor_mistral_openorca(a::agentReflex)
|
||||
# context = replace(context, "{earlierConversation}" => "My earlier talk with the user:\n$(a.earlierConversation)")
|
||||
context = replace(context, "{env state}" => "")
|
||||
context = replace(context, "{longterm memory}" => "")
|
||||
context = replace(context, "{plan}" => "Plan:\n$(a.memory[:shortterm]["Plan 1:"])")
|
||||
context = replace(context, "{plan}" => "My plan:\n$(a.memory[:shortterm]["Plan 1:"])")
|
||||
prompt = replace(prompt, "{context}" => context)
|
||||
|
||||
return prompt
|
||||
@@ -618,11 +619,12 @@ function work(a::agentReflex, usermsg::String)
|
||||
a.earlierConversation = conversationSummary(a)
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
a.memory[:shortterm]["user:"] = usermsg
|
||||
@show a.memory[:shortterm]
|
||||
a.memory[:log]["user:"] = usermsg
|
||||
elseif a.thinkingmode == :continue_thinking #TODO
|
||||
error("continue_thinking $(@__LINE__)")
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
a.thought *= "Obs $(a.attempt): $usermsg\n"
|
||||
a.memory[:shortterm]["Obs $(a.step):"] = usermsg
|
||||
a.memory[:log]["Obs $(a.step):"] = usermsg
|
||||
else
|
||||
error("undefined condition thinkingmode = $thinkingmode $(@__LINE__)")
|
||||
end
|
||||
@@ -641,13 +643,16 @@ function work(a::agentReflex, usermsg::String)
|
||||
respond = sendReceivePrompt(a, prompt)
|
||||
|
||||
# sometimes LLM add not-need word I don't want
|
||||
plan = split(respond, "<|im_end|>")[1]
|
||||
plan = split(plan, "Response:")[1]
|
||||
plan = split(plan, "Execution:")[1]
|
||||
plan = split(plan, "Result:")[1]
|
||||
# plan = split(respond, "<|im_end|>")[1]
|
||||
# plan = split(plan, "Response:")[1]
|
||||
# plan = split(plan, "Execution:")[1]
|
||||
# plan = split(plan, "Result:")[1]
|
||||
# plan = split(plan, "Recommendation:")[1]
|
||||
plan = splitext(plan, ["<|im_end|>", "Response:", "Execution:", "Result:", "Recommendation:"])
|
||||
|
||||
plan = replace(plan, "Plan:"=>"")
|
||||
a.memory[:shortterm]["Plan $(a.attempt):"] = plan
|
||||
a.memory[:log]["Plan $(a.attempt):"] = plan
|
||||
actorstate, msgToUser = actor(a)
|
||||
|
||||
if actorstate == "chatbox"
|
||||
@@ -658,7 +663,8 @@ function work(a::agentReflex, usermsg::String)
|
||||
|
||||
respond = formulateRespond(a)
|
||||
error("10")
|
||||
a.memory[:shortterm]["Respond:"] = respond
|
||||
a.memory[:shortterm]["Respond $(a.attempt):"] = respond
|
||||
a.memory[:log]["Respond $(a.attempt):"] = respond
|
||||
|
||||
# evaluate. if score < 8/10 try again.
|
||||
guideline = writeEvaluationGuideline(a, a.memory[:shortterm]["user:"])
|
||||
@@ -668,11 +674,12 @@ function work(a::agentReflex, usermsg::String)
|
||||
if score >= 8 # good enough answer
|
||||
@show a.memory[:shortterm]
|
||||
a.memory[:shortterm] = OrderedDict{String, Any}()
|
||||
a.memory[:log] = OrderedDict{String, Any}()
|
||||
break
|
||||
else # self evaluate and reflect then try again
|
||||
analysis = analyze(a, a.memory[:shortterm])
|
||||
@show analysis
|
||||
|
||||
error(12)
|
||||
lessonwithcontext = selfReflext(a, analysis)
|
||||
@show lessonwithcontext
|
||||
a.memory[:shortterm] = OrderedDict{String, Any}()
|
||||
@@ -784,10 +791,10 @@ function actor(a::agentReflex)
|
||||
@show toolresult
|
||||
a.memory[:shortterm]["Obs $(a.step):"] = toolresult
|
||||
|
||||
#WORKING goNogo
|
||||
go = goNogo(a)
|
||||
@show go
|
||||
error(11)
|
||||
if go == "No" # in case there is a cancel, go straight to evaluation
|
||||
a.step = totalsteps
|
||||
end
|
||||
end
|
||||
else #TODO finish all steps
|
||||
actorState = "all steps done"
|
||||
@@ -1099,7 +1106,7 @@ julia> shorttermMemory = OrderedDict{String, Any}(
|
||||
julia> decision = goNogo(agent)
|
||||
"Yes"
|
||||
```
|
||||
""" #WORKING
|
||||
"""
|
||||
function goNogo(a)
|
||||
stimulus = a.memory[:shortterm]["user:"]
|
||||
work = ""
|
||||
|
||||
Reference in New Issue
Block a user