update
This commit is contained in:
@@ -230,7 +230,7 @@ function planner_mistral_openorca(a::agentReflex)
|
||||
</s>
|
||||
$conversation
|
||||
<|assistant|>
|
||||
|
||||
Plan:
|
||||
"""
|
||||
|
||||
response = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=1024, temperature=0.1,
|
||||
@@ -238,7 +238,7 @@ function planner_mistral_openorca(a::agentReflex)
|
||||
response = split(response, "<|")[1]
|
||||
response = split(response, "</")[1]
|
||||
response = split(response, "\n\n")[1]
|
||||
@show response
|
||||
@show response = "Plan: " * response
|
||||
|
||||
headerToDetect = ["Plan:", "Keyword memory:",]
|
||||
headers = detectCharacters(response, headerToDetect)
|
||||
@@ -276,9 +276,9 @@ function updatePlan(a::agentReflex)
|
||||
<s>
|
||||
<|system|>
|
||||
$(a.roles[a.role])
|
||||
Request the user’s input for the following info initially, and use alternative sources of information only if they are unable to provide it:
|
||||
Request the user’s input for the following info before you could search wine stock:
|
||||
- occasion
|
||||
- type of food ask the user
|
||||
- food pair ask the user
|
||||
- user's personal taste of wine
|
||||
- ambient temperature at the serving location
|
||||
- wine price range
|
||||
@@ -889,16 +889,15 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
|
||||
$(a.roles[a.role])
|
||||
"""
|
||||
|
||||
winestocksearchresult = nothing
|
||||
if haskey(a.memory, :winestocksearchresult) && a.memory[:winestockResult] !== nothing
|
||||
winestocksearchresult =
|
||||
"""
|
||||
<winestock search result>
|
||||
$(a.memory[:winestocksearchresult])
|
||||
</winestock search result>
|
||||
"""
|
||||
else
|
||||
winestocksearchresult = "\n"
|
||||
winestocksearchresult = false
|
||||
if haskey(a.memory, :winestock) && a.memory[:winestock] !== nothing
|
||||
# winestocksearchresult =
|
||||
# """
|
||||
# <winestock search result>
|
||||
# $(a.memory[:winestock])
|
||||
# </winestock search result>
|
||||
# """
|
||||
winestocksearchresult = true
|
||||
end
|
||||
|
||||
keywordmemory = ""
|
||||
@@ -919,8 +918,10 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
|
||||
- Luxury level is high
|
||||
{\"car type\": "SUV",\"brand\":\"Lexus\",\"price\":\"200000\",\"color\": null,\"financing method\": null, \"luxury level\":\"high\"}
|
||||
"""
|
||||
|
||||
prompt =
|
||||
#WORKING actor donot call final reapond after found matched wines because the current prompt
|
||||
# does not contain a.memory[:shortterm] and Thought: do not look for mached wine. Therefore, LLM
|
||||
# did not see matched wine info
|
||||
prompt_1 =
|
||||
"""
|
||||
<s>
|
||||
<|system|>
|
||||
@@ -933,7 +934,8 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
|
||||
</You have access to the following tools>
|
||||
<Your job>
|
||||
Use the following format:
|
||||
Thought: based on what you know about user, you should pay attention on what you don't know first then check out your plan. (PS. 1. let's think only one thing at a time. 2. pay attention to correct numeral calculation and commonsense.)
|
||||
Recall: you must explicitly state each info you did't know about the user
|
||||
Thought: Based on the recall, you must think about what is the immediate next step to do according to the plan and you must address what you didn't know urgently if you have one (PS. 1. pay attention to correct numeral calculation and commonsense.)
|
||||
Act: based on your thought what action to choose?, must be one of [{toolnames}].
|
||||
Actinput: your input to the action using JSON format (pay attention to the tool's input)
|
||||
Obs: observed result of the action
|
||||
@@ -946,10 +948,41 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
|
||||
<User info>
|
||||
$keywordmemory
|
||||
</User info>
|
||||
$winestocksearchresult
|
||||
<|assistant|>
|
||||
Recall:
|
||||
"""
|
||||
|
||||
prompt_2 =
|
||||
"""
|
||||
<s>
|
||||
<|system|>
|
||||
<About yourself>
|
||||
Your name is $(a.agentName)
|
||||
$(a.roles[a.role])
|
||||
</About yourself>
|
||||
<You have access to the following tools>
|
||||
$toollines
|
||||
</You have access to the following tools>
|
||||
<Your job>
|
||||
Use the following format:
|
||||
Thought: you always check your plan and explicitly state what you are going to do next. (PS. 1. let's think only one thing at a time. 2. pay attention to correct numeral calculation and commonsense.)
|
||||
Act: based on your thought what action to choose?, must be one of [{toolnames}].
|
||||
Actinput: your input to the action using JSON format (pay attention to the tool's input)
|
||||
Obs: observed result of the action
|
||||
</Your job>
|
||||
</|system|>
|
||||
</s>
|
||||
$(dictToString(a.memory[:shortterm]))
|
||||
<|assistant|>
|
||||
Thought:
|
||||
"""
|
||||
|
||||
prompt = prompt_1
|
||||
if winestocksearchresult
|
||||
prompt = prompt_2
|
||||
end
|
||||
|
||||
prompt = replace(prompt, "{toolnames}" => toolnames)
|
||||
|
||||
println("")
|
||||
@@ -961,7 +994,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
|
||||
|
||||
while true # while Thought or Act is empty, run actor again
|
||||
|
||||
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=0.5, timeout=300,
|
||||
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=0.4, timeout=300,
|
||||
stopword=["Thought:", "Obs:", "<|system|>", "</s>", "<|end|>"],
|
||||
seed=rand(1000000:2000000))
|
||||
println("")
|
||||
@@ -1331,7 +1364,7 @@ function actor(a::agentReflex)
|
||||
msgToUser = askbox(toolinput)
|
||||
actorState = toolname
|
||||
|
||||
#WORKING add only a single Q1 to memory because LLM need to ask the user only 1 question at a time
|
||||
# add only a single Q1 to memory because LLM need to ask the user only 1 question at a time
|
||||
latestTask = shortMemLatestTask(a.memory[:shortterm]) +1
|
||||
chunkedtext["Actinput $latestTask:"] = msgToUser
|
||||
addShortMem!(a.memory[:shortterm], chunkedtext)
|
||||
@@ -1341,27 +1374,19 @@ function actor(a::agentReflex)
|
||||
addShortMem!(a.memory[:shortterm], chunkedtext)
|
||||
println(">>> already done")
|
||||
actorState = "formulateFinalResponse"
|
||||
error(5555)
|
||||
|
||||
break
|
||||
else # function call
|
||||
addShortMem!(a.memory[:shortterm], chunkedtext)
|
||||
f = a.tools[toolname][:func]
|
||||
toolresult = f(a, actorResult)
|
||||
@show toolresult
|
||||
if toolname == ""
|
||||
a.memory[:shortterm]["Obs $latestTask:"] = "I found wines in <winestock search result>"
|
||||
a.memory[:winestockResult] = toolresult
|
||||
a.memory[:log]["Obs $latestTask:"] = "winestock search done"
|
||||
else
|
||||
a.memory[:shortterm]["Obs $latestTask:"] = toolresult
|
||||
a.memory[:log]["Obs $latestTask:"] = toolresult
|
||||
if toolname == "winestock"
|
||||
a.memory[:winestock] = toolresult
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
a.memory[:shortterm]["Obs $latestTask:"] = toolresult
|
||||
a.memory[:log]["Obs $latestTask:"] = toolresult
|
||||
end
|
||||
end
|
||||
|
||||
return actorState, msgToUser
|
||||
|
||||
Reference in New Issue
Block a user