add new version

This commit is contained in:
2023-11-21 07:00:01 +00:00
parent 5d4bcb05d7
commit 1281c5b3df
6 changed files with 2261 additions and 101 deletions

View File

@@ -72,7 +72,7 @@ function agentReact(
roles::Dict=Dict(
:assistant =>
"""
You are a helpful assistant that answer the user's questions as best you can.
You are a helpful assistant who answer the user's questions as best you can.
""",
:sommelier =>
"""
@@ -501,106 +501,6 @@ function work(a::T, prompt::String, maxround::Int=3) where {T<:agent}
return respond
end
# function work(a::T, prompt::String, maxround::Int=3) where {T<:agent}
# respond = nothing
# while true
# a.thoughtround += 1
# toolname = nothing
# toolinput = nothing
# if a.thoughtround > a.thoughtlimit
# a.thought *= "Thought $(a.thoughtround): I think I know the answer."
# prompt = a.thought
# end
# @show prompt
# respond = sendReceivePrompt(a, prompt)
# headerToDetect = nothing
# if a.thoughtround == 1
# try
# respond = split(respond, "Obs:")[1]
# @show respond
# headerToDetect = ["Question:", "Plan:", "Thought:", "Act:", "ActInput:", "Obs:", "...", "Answer:",
# "Conclusion:", "Summary:"]
# catch
# end
# else
# try
# respond = split(respond, "Obs $(a.thoughtround):")[1]
# @show respond
# headerToDetect = ["Question $(a.thoughtround):", "Plan $(a.thoughtround):",
# "Thought $(a.thoughtround):", "Act $(a.thoughtround):",
# "ActInput $(a.thoughtround):", "Obs $(a.thoughtround):",
# "...", "Answer:",
# "Conclusion:", "Summary:"]
# catch
# end
# end
# headers = detectCharacters(respond, headerToDetect)
# chunkedtext = chunktext(respond, headers)
# @show chunkedtext
# if a.thought == "nothing"
# thought = ""
# for i in chunkedtext
# header = i[:header]
# header = replace(header, ":"=>" $(a.thoughtround):") # add number so that llm not confused
# body = i[:body]
# thought *= "$header $body"
# end
# a.thought = prompt * thought
# else
# a.thought *= respond
# end
# Answer = findDetectedCharacter(headers, "Answer:")
# AnswerInd = length(Answer) != 0 ? Answer[1] : nothing
# Act = findDetectedCharacter(headers, "Act $(a.thoughtround):")
# if length(Answer) == 1 && length(Act) == 0
# a.thought = "nothing" # question finished, no more thought
# a.thoughtround = 0
# respond = chunkedtext[AnswerInd][:body]
# _ = addNewMessage(a, "assistant", respond)
# break
# else
# # check for tool being called
# ActHeader = a.thoughtround == 1 ? "Act:" : "Act $(a.thoughtround):"
# ActInd = findDetectedCharacter(headers, ActHeader)[1]
# toolname = toolNameBeingCalled(chunkedtext[ActInd][:body], a.tools)
# toolinput = chunkedtext[ActInd+1][:body]
# if occursin(" \"", toolinput)
# toolinput = GeneralUtils.getStringBetweenCharacters(toolinput, " \"", "\"\n")
# else
# toolinput = GeneralUtils.getStringBetweenCharacters(toolinput, " ", "\n")
# end
# @show toolname
# @show toolinput
# if toolname == "chatbox" # chat with user
# a.thought *= toolinput
# respond = toolinput
# _ = addNewMessage(a, "assistant", respond)
# break
# else # function call
# println("//////////// $(a.thoughtround)")
# f = a.tools[Symbol(toolname)][:func]
# _result = f(toolinput)
# if _result != "No info available." #TODO for use with wikisearch(). Not good for other tools
# _result = makeSummary(a, _result)
# end
# result = "Obs $(a.thoughtround): $_result\n"
# a.thought *= result
# prompt = a.thought
# end
# end
# end
# @show respond
# return respond
# end
"""
make a conversation summary.
```jldoctest