update
This commit is contained in:
@@ -631,6 +631,8 @@ function work(a::agentReflex, usermsg::String)
|
||||
|
||||
if a.thinkingmode == :new_thinking
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
a.memory[:shortterm] = OrderedDict{String, Any}()
|
||||
a.memory[:log] = OrderedDict{String, Any}()
|
||||
a.memory[:shortterm]["user:"] = usermsg
|
||||
a.memory[:log]["user:"] = usermsg
|
||||
a.newplan = true
|
||||
@@ -655,9 +657,7 @@ function work(a::agentReflex, usermsg::String)
|
||||
println("")
|
||||
@show prompt_plan
|
||||
respond = sendReceivePrompt(a, prompt_plan, max_tokens=1024)
|
||||
println("")
|
||||
plan_raw = respond
|
||||
@show plan_raw
|
||||
|
||||
# sometimes LLM add not-need word I don't want
|
||||
plan = splittext(respond, ["Step 1", "<|im_end|>", "Response", "Execution",
|
||||
"Result", "Recommendation", "My response"])
|
||||
@@ -670,8 +670,8 @@ function work(a::agentReflex, usermsg::String)
|
||||
a.memory[:log]["Plan $(a.attempt):"] = plan
|
||||
end
|
||||
|
||||
println("")
|
||||
@show a.attempt
|
||||
@show a.memory[:shortterm]["user:"]
|
||||
|
||||
# enter actor loop
|
||||
actorstate, msgToUser = actor(a)
|
||||
@@ -693,18 +693,22 @@ function work(a::agentReflex, usermsg::String)
|
||||
|
||||
# evaluate. if score < 8/10 try again.
|
||||
guideline = writeEvaluationGuideline(a, a.memory[:shortterm]["user:"])
|
||||
|
||||
println("")
|
||||
@show guideline
|
||||
|
||||
score = grading(a, guideline, respond)
|
||||
@show score
|
||||
if score >= 8 # good enough answer
|
||||
@show a.memory[:shortterm]
|
||||
a.memory[:shortterm] = OrderedDict{String, Any}()
|
||||
a.memory[:log] = OrderedDict{String, Any}()
|
||||
if score >= 6 # good enough answer
|
||||
break
|
||||
else # self evaluate and reflect then try again
|
||||
analysis = analyze(a)
|
||||
println("")
|
||||
@show analysis
|
||||
|
||||
lessonwithcontext = selfReflext(a, analysis)
|
||||
|
||||
println("")
|
||||
@show lessonwithcontext
|
||||
|
||||
newdict = OrderedDict()
|
||||
@@ -714,10 +718,13 @@ function work(a::agentReflex, usermsg::String)
|
||||
headerToDetect = ["Lesson:", "Context:", ]
|
||||
headers = detectCharacters(lessonwithcontext, headerToDetect)
|
||||
chunkedtext = chunktext(lessonwithcontext, headers)
|
||||
@show chunkedtext
|
||||
|
||||
a.memory[:longterm][chunkedtext["Context:"]] = chunkedtext["Lesson:"]
|
||||
a.newplan = true
|
||||
println("")
|
||||
println("RETRY $(a.attempt +1)")
|
||||
println("")
|
||||
|
||||
end
|
||||
else
|
||||
error("undefied condition, actorstate $actorstate $(@__LINE__)")
|
||||
@@ -796,13 +803,13 @@ function actor(a::agentReflex)
|
||||
if a.step < totalsteps
|
||||
|
||||
prompt_actor = actor_mistral_openorca(a)
|
||||
|
||||
println("")
|
||||
@show prompt_actor
|
||||
|
||||
respond = sendReceivePrompt(a, prompt_actor)
|
||||
respond = splittext(respond, ["Obs", "<|im_end|>"])
|
||||
respond_actor_raw = respond
|
||||
println("")
|
||||
@show respond_actor_raw
|
||||
|
||||
if !occursin("Thought", respond)
|
||||
respond = "Thought: " * respond
|
||||
end
|
||||
@@ -816,8 +823,8 @@ function actor(a::agentReflex)
|
||||
|
||||
headers = detectCharacters(respond, headerToDetect)
|
||||
|
||||
respond_actor = respond
|
||||
println("")
|
||||
respond_actor = respond
|
||||
@show respond_actor
|
||||
|
||||
headerToDetect = ["Plan $(a.attempt):",
|
||||
@@ -828,7 +835,7 @@ function actor(a::agentReflex)
|
||||
"Check $(a.step):",]
|
||||
headers = detectCharacters(respond, headerToDetect)
|
||||
chunkedtext = chunktext(respond, headers)
|
||||
@show chunkedtext
|
||||
|
||||
|
||||
# add to memory
|
||||
a.memory[:shortterm] = addShortMem!(a.memory[:shortterm], chunkedtext)
|
||||
@@ -1220,9 +1227,7 @@ function goNogo(a)
|
||||
|
||||
respond = sendReceivePrompt(a, prompt)
|
||||
|
||||
println("")
|
||||
goNogo_raw = respond
|
||||
@show goNogo_raw
|
||||
|
||||
|
||||
decision = nothing
|
||||
reason = nothing
|
||||
|
||||
Reference in New Issue
Block a user