This commit is contained in:
2023-12-08 12:50:34 +00:00
parent 7442a9f63b
commit 804ec35da6
3 changed files with 108 additions and 156 deletions

View File

@@ -357,9 +357,8 @@ function chooseThinkingMode(a::agentReflex, usermsg::String)
Your job is to determine whether you will use tools or actions to respond.
Choose one of the following choices:
If you don't need to use tools or actions to respond to the stimulus say, "{no}".
If you need tools or actions to respond to the stimulus say, "{yes}".
If the user want to get wine say, "{yes}".
Choice 1: If the user want to get wine say, "{yes}".
Choice 2: If you don't need to use tools or actions to respond to the stimulus say, "{no}".
<|im_end|>
<|im_start|>user
@@ -387,6 +386,97 @@ function chooseThinkingMode(a::agentReflex, usermsg::String)
end
# function chooseThinkingMode(a::agentReflex, usermsg::String)
# thinkingmode = nothing
# if length(a.memory[:log]) != 0
# thinkingmode = :continue_thinking
# else
# prompt =
# """
# <|im_start|>system
# {systemMsg}
# You always use tools if there is a chance to impove your respond.
# You have access to the following tools:
# {tools}
# Your job is to determine whether you will use tools or actions to respond.
# Choose one of the following choices:
# Choice 1: If you don't need to use tools or actions to respond to the stimulus say, "{no}".
# Choice 2: If you think the user want to get wine say, "{yes}".
# <|im_end|>
# <|im_start|>user
# {input}
# <|im_end|>
# <|im_start|>assistant
# """
# toollines = ""
# for (toolname, v) in a.tools
# if toolname ∉ ["chatbox", "nothing"]
# toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
# toollines *= toolline
# end
# end
# prompt = replace(prompt, "{systemMsg}" => a.roles[a.role])
# prompt = replace(prompt, "{tools}" => toollines)
# prompt = replace(prompt, "{input}" => usermsg)
# result = sendReceivePrompt(a, prompt)
# willusetools = GeneralUtils.getStringBetweenCharacters(result, "{", "}")
# thinkingmode = willusetools == "yes" ? :new_thinking : :no_thinking
# end
# return thinkingmode
# end
function chooseThinkingMode(a::agentReflex, usermsg::String)
thinkingmode = nothing
if length(a.memory[:log]) != 0
thinkingmode = :continue_thinking
else
prompt =
"""
<|im_start|>system
{systemMsg}
You always use tools if there is a chance to impove your respond.
You have access to the following tools:
{tools}
User message:
{input}
Your job is to determine the following topics:
Topic 1: Is the user message show that they would like to get some wine? {Yes/No}
Topic 2: Is the user message show that they would like to get some cloth? {Yes/No}
<|im_end|>
<|im_start|>assistant
"""
toollines = ""
for (toolname, v) in a.tools
if toolname ["chatbox", "nothing"]
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
toollines *= toolline
end
end
prompt = replace(prompt, "{systemMsg}" => a.roles[a.role])
prompt = replace(prompt, "{tools}" => toollines)
prompt = replace(prompt, "{input}" => usermsg)
result = sendReceivePrompt(a, prompt)
headers = detectCharacters(lessonwithcontext, ["Topic 1:", "Topic 2:"])
chunkedtext = chunktext(result, headers)
@show chunkedtext
error(11)
willusetools = GeneralUtils.getStringBetweenCharacters(result, "{", "}")
thinkingmode = willusetools == "Yes" ? :new_thinking : :no_thinking
end
@show result
error(11)
return thinkingmode
end