This commit is contained in:
2024-01-01 11:51:51 +00:00
parent 41c5fe3963
commit 2f33c7fea0
3 changed files with 101 additions and 75 deletions

View File

@@ -123,19 +123,27 @@ function chat_mistral_openorca(a::agentReflex)
conversation = messagesToString(a.messages)
aboutYourself =
"""
Your name is $(a.agentName)
$(a.roles[a.role])
"""
prompt =
"""
<|system|>
$(a.roles[a.role])
Your earlier talk with the user:
$(a.earlierConversation)
<About yourself>
$aboutYourself
</About yourself>
<Your earlier talk with the user>
$(a.earlierConversation)
</Your earlier talk with the user>
</s>
$conversation
<|assistant|>
"""
response = sendReceivePrompt(a, prompt, timeout=180)
response = split(response, "<|im_end|>")[1]
response = sendReceivePrompt(a, prompt, timeout=180, stopword=["<|", "</"])
return response
end
@@ -180,38 +188,38 @@ function planner_mistral_openorca(a::agentReflex)
# skip objective and plan because LLM is going to generate new plan
shorttermMemory = dictToString(a.memory[:shortterm], skiplist=["Objective:", "Plan 1:"])
aboutYourself =
"""
Your name is $(a.agentName)
$(a.roles[a.role])
"""
assistant_plan_prompt =
"""
<|system|>
$(a.roles[a.role])
Required info you need for wine recommendation:
- occasion: ask the user
- type of food that will be served with wine: ask the user
- ambient temperature at the serving location: ask the user
- type of wine (Rose, White, Red and Sparkling): ask the user
- user's personal taste of wine characteristic: ask the user
- wine price range: ask the user
- wines we have in stock: use winestock tool
You have access to the following tools:
$toollines
Your earlier work:
$shorttermMemory
Your job is to do the following:
Plan: first you should always think about your conversation with the user and your earlier work thoroughly then extract and devise a complete, task by task plan to achieve your objective (pay attention to correct numeral calculation and commonsense).
P.S.1 each task of the plan should be a single action.
<About yourself>
$aboutYourself
</About yourself>
<You have access to the following tools>
$toollines
</You have access to the following tools
<Your earlier work>
$shorttermMemory
</Your earlier work>
<Your job>
Plan: first you should always think about your conversation with the user and your earlier work thoroughly then extract and devise a complete, task by task plan to achieve your objective (pay attention to correct numeral calculation and commonsense).
P.S.1 each task of the plan should be a single action.
</Your job>
</s>
$conversation
<|assistant|>
Plan:
"""
plan = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=512, temperature=0.1)
plan = split(plan, "<|")[1]
plan = split(plan, "\n\n")[1]
plan = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=512, temperature=0.1, stopword=["<|", "</"])
# plan = split(plan, "<|")[1]
# plan = split(plan, "\n\n")[1]
return plan
end
@@ -358,10 +366,18 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
"""
end
aboutYourself =
"""
Your name is $(a.agentName)
$(a.roles[a.role])
"""
prompt =
"""
<|system|>
$(a.roles[a.role])
<About yourself>
$aboutYourself
</About yourself>
<You have access to the following tools>
$toollines
</You have access to the following tools>
@@ -395,7 +411,8 @@ function actor_mistral_openorca(a::agentReflex, taskrecap="")
while true # while Thought or Act is empty, run actor again
tempcounter += 0.2
@show tempcounter
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=tempcounter, timeout=180)
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=tempcounter, timeout=180,
stopword=["/n/n", "END", "End", "Obs", "<|", "</"])
response = splittext(response, ["/n/n", "END", "End", "Obs", "<|im_end|>"])
latestTask = shortMemLatestTask(a.memory[:shortterm]) +1