update
This commit is contained in:
142
src/interface.jl
142
src/interface.jl
@@ -457,8 +457,8 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
isusetools = isUseTools(a, usermsg)
|
||||
newinfo = extractinfo(a, usermsg)
|
||||
a.env = newinfo !== nothing ? updateEnvState(a, newinfo)
|
||||
|
||||
a.env = newinfo !== nothing ? updateEnvState(a, newinfo) : a.env
|
||||
error(1)
|
||||
#WORKING
|
||||
if isusetools # use tools before responseing
|
||||
response = work(a, usermsg)
|
||||
@@ -485,21 +485,11 @@ end
|
||||
function work(a::agentReflex, usermsg::String)
|
||||
response = nothing
|
||||
|
||||
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
|
||||
elseif a.thinkingmode == :continue_thinking
|
||||
println("continue_thinking!!")
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
a.memory[:shortterm]["Obs $(a.step):"] = usermsg
|
||||
a.memory[:log]["Obs $(a.step):"] = usermsg
|
||||
else
|
||||
error("undefined condition thinkingmode = $thinkingmode $(@__LINE__)")
|
||||
end
|
||||
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
|
||||
|
||||
while true # Work loop
|
||||
# plan
|
||||
@@ -600,6 +590,124 @@ function work(a::agentReflex, usermsg::String)
|
||||
return response
|
||||
end
|
||||
|
||||
# function work(a::agentReflex, usermsg::String)
|
||||
# response = nothing
|
||||
|
||||
# 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
|
||||
# elseif a.thinkingmode == :continue_thinking
|
||||
# println("continue_thinking!!")
|
||||
# _ = addNewMessage(a, "user", usermsg)
|
||||
# a.memory[:shortterm]["Obs $(a.step):"] = usermsg
|
||||
# a.memory[:log]["Obs $(a.step):"] = usermsg
|
||||
# else
|
||||
# error("undefined condition thinkingmode = $thinkingmode $(@__LINE__)")
|
||||
# end
|
||||
|
||||
# while true # Work loop
|
||||
# # plan
|
||||
# if a.attempt <= a.attemptlimit
|
||||
# toolname = nothing
|
||||
# toolinput = nothing
|
||||
# if a.newplan == true
|
||||
# a.attempt += 1
|
||||
# a.step = 0
|
||||
# prompt_plan = planner_mistral_openorca(a)
|
||||
# println("")
|
||||
# @show prompt_plan
|
||||
# response = sendReceivePrompt(a, prompt_plan, max_tokens=1024)
|
||||
|
||||
# # sometimes LLM add not-need word I don't want
|
||||
# plan = splittext(response, ["Step 1", "<|im_end|>", "Response", "Execution",
|
||||
# "Result", "Recommendation", "My response"])
|
||||
# # plan = replace(plan, "Plan:"=>"")
|
||||
# println("")
|
||||
# @show plan
|
||||
|
||||
# a.newplan = false
|
||||
# a.memory[:shortterm]["Plan $(a.attempt):"] = plan
|
||||
# a.memory[:log]["Plan $(a.attempt):"] = plan
|
||||
# end
|
||||
|
||||
# println("")
|
||||
# @show a.attempt
|
||||
|
||||
# # enter actor loop
|
||||
# actorstate, msgToUser = actor(a)
|
||||
|
||||
# if actorstate == "chatbox"
|
||||
# response = msgToUser
|
||||
# break
|
||||
# elseif actorstate == "all steps done" || actorstate == "formulateUserresponse"
|
||||
# println("all steps done")
|
||||
|
||||
# response = formulateUserresponse(a)
|
||||
|
||||
# println("")
|
||||
# formulatedresponse = response
|
||||
# @show formulatedresponse
|
||||
|
||||
# a.memory[:shortterm]["response $(a.attempt):"] = response
|
||||
# a.memory[:log]["response $(a.attempt):"] = response
|
||||
|
||||
# # evaluate. if score < 8/10 try again.
|
||||
# guideline = writeEvaluationGuideline(a, a.memory[:shortterm]["user:"])
|
||||
|
||||
# println("")
|
||||
# @show guideline
|
||||
|
||||
# score = grading(a, guideline, response)
|
||||
# @show score
|
||||
# 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()
|
||||
|
||||
# a.memory[:shortterm] = keepOnlyKeys(a.memory[:shortterm], ["user:"])
|
||||
|
||||
# headerToDetect = ["Lesson:", "Context:", ]
|
||||
# headers = detectCharacters(lessonwithcontext, headerToDetect)
|
||||
# chunkedtext = chunktext(lessonwithcontext, headers)
|
||||
|
||||
# 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__)")
|
||||
# break
|
||||
# end
|
||||
# else
|
||||
# error("attempt limit reach")
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
|
||||
# # good enough answer
|
||||
|
||||
|
||||
# # communicates with user
|
||||
# _ = addNewMessage(a, "assistant", response)
|
||||
# return response
|
||||
# end
|
||||
|
||||
|
||||
# function evaluate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user