This commit is contained in:
2023-12-29 15:13:57 +00:00
parent 02a00aa82f
commit 6d9b383404

View File

@@ -477,202 +477,6 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
return toolname, toolinput, chunkedtext
end
# function actor_mistral_openorca(a::agentReflex, taskrecap="")
# getonlykeys = ["Actinput", "Obs"]
# worknoplan = similar(a.memory[:shortterm])
# for (k, v) in a.memory[:shortterm]
# count = 0
# for i in getonlykeys
# if occursin(i, k)
# count += 1
# end
# end
# if count != 0
# worknoplan[k] = v
# end
# end
# work = dictToString(worknoplan)
# """
# general prompt format:
# "
# <|im_start|>system
# {role}
# {tools}
# {thinkingFormat}
# <|im_end|>
# {context}
# <|im_start|>user
# {usermsg}
# <|im_end|>
# <|im_start|>assistant
# "
# Note:
# {context} =
# "
# {earlierConversation}
# {env state}
# {shortterm memory}
# {longterm memory}
# "
# """
# #BUG BIG output from winestock cause recap() to fail.
# #BUG2 LLM repeat winestock search without recommending wine
# toolnames = ""
# toollines = ""
# for (toolname, v) in a.tools
# toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
# toollines *= toolline
# toolnames *= "$toolname, "
# end
# # shorttermMemory = dictToString(a.memory[:shortterm], skiplist=["user:"])
# # conversation = conversationSummary(a)
# # println("")
# # @show conversationSum = conversation
# # context =
# # """
# # Your talk with the user:
# # $conversation
# # """
# start = "Thought"
# aware = ""
# if taskrecap != ""
# start = "Self-awareness"
# # aware = "Self-awareness: based on the recap, assess your progress against the plan then identify areas where you need to address."
# # aware = "Self-awareness: based on the recap and the plan, state your current understanding of the matter in details then identify areas where you need to address."
# aware = "Self-awareness: based on the recap, check your progress against the plan and assess the current situation to identify tasks that you need to address."
# end
# winestockResult = ""
# if a.winestockResult != ""
# winestockResult =
# """
# <winestock search result>
# $(a.winestockResult)
# </winestock search result>
# """
# end
# prompt =
# """
# <|system|>
# $(a.roles[a.role])
# <You have access to the following tools>
# $toollines
# </You have access to the following tools>
# <Your plan>
# $(a.memory[:shortterm]["Plan 1:"])
# </Your plan>
# <Your earlier work's recap>
# $work
# </Your earlier work's recap>
# $winestockResult
# <Your job>
# Use the following format:
# $aware
# Thought: based on the plan and self-awareness, What to do? (P.S.1 pay attention to correct numeral calculation and commonsense.)
# Act: an action to take based on your thought, must be one of [{toolnames}]
# Actinput: your input to the action based on your thought (pay attention to the tool's input)
# Obs: observed result of the action
# </Your job>
# </s>
# <|assistant|>
# $start:
# """
# prompt = replace(prompt, "{toolnames}" => toolnames)
# println("")
# @show actor_prompt = prompt
# response = nothing
# chunkedtext = nothing
# latestTask = nothing
# tempcounter = 0.2
# while true # while Thought or Act is empty, run actor again
# # tempcounter += 0.1
# @show tempcounter
# response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=tempcounter)
# response = splittext(response, ["Obs", "<|im_end|>"])
# latestTask = shortMemLatestTask(a.memory[:shortterm]) +1
# if start == "Thought"
# response = "Thought $latestTask: " * response
# else
# response = "Self-awareness $latestTask: " * response
# end
# headerToDetect = ["Question:", "Plan:", "Self-awareness:", "Thought:",
# "Act:", "Actinput:", "Obs:", "...",
# "Answer:", "Conclusion:", "Summary:"]
# # replace headers with headers with correct attempt and task number
# response = replaceHeaders(response, headerToDetect, latestTask)
# response = split(response, "<|")[1]
# response = split(response, "</")[1]
# headers = detectCharacters(response, headerToDetect)
# println("")
# headerToDetect = ["Plan $(a.attempt):",
# "Self-awareness $latestTask:",
# "Thought $latestTask:",
# "Act $latestTask:",
# "Actinput $latestTask:",
# "Obs $latestTask:",
# "Check $latestTask:",]
# headers = detectCharacters(response, headerToDetect)
# chunkedtext = chunktext(response, headers)
# # assuming length more than 10 character means LLM has valid thinking
# @show iskey_Thought = haskey(chunkedtext, "Thought $latestTask:")
# @show iskey_Act = haskey(chunkedtext, "Act $latestTask:")
# @show iskey_Actinput = haskey(chunkedtext, "Actinput $latestTask:")
# if iskey_Thought && iskey_Act && iskey_Actinput
# if chunkedtext["Thought $latestTask:"] != " " && chunkedtext["Act $latestTask:"] != " " &&
# length(chunkedtext["Actinput $latestTask:"]) > 5
# break
# end
# end
# end
# toolname = toolNameBeingCalled(chunkedtext["Act $latestTask:"], a.tools)
# toolinput = chunkedtext["Actinput $latestTask:"]
# # change trailing number to continue a.memory[:shortterm]
# headerToDetect = ["Question:", "Plan:", "Self-awareness:", "Thought:",
# "Act:", "Actinput:", "Obs:", "...",
# "Answer:", "Conclusion:", "Summary:"]
# response = replaceHeaders(response, headerToDetect, latestTask)
# println("")
# @show actor_response = response
# headerToDetect = ["Plan $(a.attempt):",
# "Thought $latestTask:",
# "Act $latestTask:",
# "Actinput $latestTask:",
# "Obs $latestTask:",
# "Check $latestTask:",]
# headers = detectCharacters(response, headerToDetect)
# chunkedtext = chunktext(response, headers)
# chunkedtext = delete!(chunkedtext, "Self-awareness $latestTask")
# return toolname, toolinput, chunkedtext
# end
"""
Chat with llm.