update conversation()
This commit is contained in:
@@ -333,39 +333,40 @@ end
|
||||
|
||||
function generatePrompt_react_mistral_openorca(a::T, usermsg::String,
|
||||
continuethought::Bool=false) where {T<:agent}
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
{systemMsg}
|
||||
You have access to the following tools:
|
||||
{tools}
|
||||
Begin!
|
||||
<|im_end|>
|
||||
Here are the context for the question:
|
||||
{context}
|
||||
"""
|
||||
prompt = replace(prompt, "{systemMsg}" => a.roles[a.role])
|
||||
|
||||
toolnames = ""
|
||||
toollines = ""
|
||||
for (toolname, v) in a.tools
|
||||
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
|
||||
toollines *= toolline
|
||||
toolnames *= "$toolname,"
|
||||
end
|
||||
prompt = replace(prompt, "{toolnames}" => toolnames)
|
||||
prompt = replace(prompt, "{tools}" => toollines)
|
||||
|
||||
prompt = replace(prompt, "{context}" => a.context)
|
||||
|
||||
if continuethought == false
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
{systemMsg}
|
||||
You have access to the following tools:
|
||||
{tools}
|
||||
Begin!
|
||||
<|im_end|>
|
||||
Here are the context for the question:
|
||||
{context}
|
||||
"""
|
||||
prompt = replace(prompt, "{systemMsg}" => a.roles[a.role])
|
||||
|
||||
toolnames = ""
|
||||
toollines = ""
|
||||
for (toolname, v) in a.tools
|
||||
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
|
||||
toollines *= toolline
|
||||
toolnames *= "$toolname,"
|
||||
end
|
||||
prompt = replace(prompt, "{toolnames}" => toolnames)
|
||||
prompt = replace(prompt, "{tools}" => toollines)
|
||||
|
||||
prompt = replace(prompt, "{context}" => a.context)
|
||||
|
||||
prompt *= "<|im_start|>user\nQTS: " * usermsg * "\n<|im_end|>\n"
|
||||
prompt *= "<|im_start|>assistant\n"
|
||||
else
|
||||
prompt *= "Obs: $usermsg\n"
|
||||
a.thought *= "Obs: $_result\n"
|
||||
prompt = a.thought
|
||||
end
|
||||
|
||||
|
||||
return prompt
|
||||
end
|
||||
|
||||
@@ -421,42 +422,22 @@ function conversation(a::T, usermsg::String) where {T<:agent}
|
||||
respond = replace(respond, "\n" => "")
|
||||
_ = addNewMessage(a, "assistant", respond)
|
||||
@show respond
|
||||
elseif userintend == "wine" #WORKING
|
||||
elseif userintend == "wine"
|
||||
if a.thought == "nothing" # new thought
|
||||
a.context = conversationSummary(a)
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
prompt = generatePrompt_react_mistral_openorca(a, usermsg)
|
||||
respond = work(a, prompt)
|
||||
else # continue thought
|
||||
|
||||
error("wine done")
|
||||
a.context = conversationSummary(a)
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
prompt = generatePrompt_react_mistral_openorca(a, usermsg, continuethought=true)
|
||||
respond = work(a, prompt)
|
||||
end
|
||||
|
||||
|
||||
elseif userintend == "thought"
|
||||
|
||||
else
|
||||
error("undefined condition userintend = $userintend")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# error("conversation done")
|
||||
return respond
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user