This commit is contained in:
2024-01-18 18:58:52 +00:00
parent 44006c3112
commit b419a5629c
4 changed files with 435 additions and 371 deletions

View File

@@ -338,7 +338,7 @@ function isUsePlans(a::agentReflex)
toollines = ""
for (toolname, v) in a.tools
if toolname ["chatbox"] # LLM will always use chatbox
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
toolline = "$toolname is $(v[:description])\n"
toollines *= toolline
end
end
@@ -360,37 +360,45 @@ function isUsePlans(a::agentReflex)
<You have access to the following tools>
$toollines
</You have access to the following tools>
<Your earlier conversation with the user>
$conversation
</Your earlier conversation with the user>
<Your job>
Your job is to decide whether you need think thoroughly or use tools in order to respond to the user's question.
Your job is to decide whether you need think thoroughly or use tools in order to respond to the user.
Use the following format:
Thought: Do you need to think thoroughly or use tools before responding to the user?
</Your job>
<Example 1>
user: Hello!. How are you?
assistant: {"thought": "the user is greeting me, I don't need to think about it.", "anwer": "no"}
assistant: The user is greeting me, I don't need to think about it.
</Example 1>
<Example 2>
user: "What's tomorrow weather like?"
assistant: {"thought": "I will need to use weather tools to check for tomorrow's temperature.", "anwer": "yes"}
assistant: I will need to use weather tools to check for tomorrow's temperature.
</Example 2>
</s>
$conversation
<|assistant|>
"""
isuseplan = false
if length(a.memory[:shortterm]) != 0
isuseplan = true
elseif a.role == :sommelier
isuseplan = true
elseif a.role == :assistant
isuseplan = false
else
# if LLM mentions any tools, use Plan/Thought/Act loop
response = sendReceivePrompt(a, prompt, temperature=0.2, max_tokens=64, stopword=["<|", "</"])
for (toolname, v) in a.tools
if occursin("Yes", String(response))
isuseplan = true
break
response = split(response, "<|")[1]
if occursin("yes", String(response))
isuseplan = true
else
for (toolname, v) in a.tools
if occursin(toolname, String(response))
isuseplan = true
break
end
end
end
end
return isuseplan
@@ -979,10 +987,6 @@ end