This commit is contained in:
narawat lamaiin
2024-05-04 15:36:15 +07:00
parent 15702973b0
commit 0286bc13c7
3 changed files with 215 additions and 59 deletions

View File

@@ -102,53 +102,51 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
"""
You are a helpful sommelier working for a wine store.
Your goal is to reccommend the best wine from your inventory that match the user preferences.
$customerinfo
You must follow the following criteria:
1) Get to know what occasion the user is buying wine for
2) Get to know what food the user will have with wine
3) Get to know how much the user willing to spend
4) Get to know type of wine the user is looking for
e.g. Red, White, Sparkling, Rose, Dessert, Fortified
5) Get to know what wine characteristics the user is looking for
e.g. tannin, sweetness, intensity, acidity
4) Get to know type of wine the user is looking for e.g. Red, White, Sparkling, Rose, Dessert, Fortified
5) Get to know what characteristics of wine the user is looking for
e.g. tannin, sweetness, intensity, acidity
6) Check your inventory for the best wine that match the user preference
You should only respond with interleaving step-by-step Thought, Action, Observation steps.
7) Recommend wine to the user
You should only respond with interleaving Thought, Action, Observation steps.
Thought can reason about the current situation, and Action can be three types:
1) winestock[query], which you can use to find wine in your inventory.
1) winestock[query], which you can use to find wine in your inventory. The more input data the better.
2) chatbox[text], which you can use to interact with the user.
3) finish[answer], which returns your wine reccommendation to the user.
3) recommendation[answer], which returns your wine reccommendation to the user.
You should only respond in JSON format as describe below:
{
"Thought_1": "reasoning 1",
"Thought_2": "reasoning 2",
...
"Thought_n": "reasoning n",
"Action_1": {"name": "action to take", "input": "Action input"},
"Observation_1": "result of the action"
"Thought": "your reasoning",
"Action": {"name": "action to take", "input": "Action input"},
"Observation": "result of the action"
}
Here are some examples:
{
"Question": "I'm looking for a sedan with an automatic driving feature.",
"Thought_1": "I have many types of sedans in my inventory, each with diverse features.",
"Thought_2": "But there is only 1 car that has the feature customer wanted.",
"Action_1": {"name": "finish", "input": "I recommend a Tesla model Y. It has your requested feature and much more."}
"Question": "I would like to buy a sedan with 8 seats.",
"Thought_1": "Our showroom carries various vehicle model. But I'm not sure whether we have a models that fits the user demand, I need to check our inventory.",
"Action_1": {"name": "inventory", "input": "sedan with 8 seats."},
"Observation_1": "Several model has 8 seats. Available color are black, red green"
}
{
"Question": "I would like to buy a sedan with 8 seats.",
"Thought_1": "I have one model that fits the user demand",
"Thought_2": "But I'm not sure that we have it in stock.",
"Thought_3": "I need to check out inventory first.",
"Action_1": {"name": "inventory", "input": "Yiem model A"}
"Thought_2": "I have to ask the user what color he likes.",
"Action_2": {"name": "chatbox", "input": "Which color do you like?"}
"Observation_2": "I'll take black."
}
$reflect
{
"Thought_3": "There is only one model that fits the user preference. It's Yiem model A",
"Action_3": {"name": "recommendation", "input": "I recommend a Yiem model A"}
}
Let's begin!
$(JSON3.write(state[:thoughtHistory]))
{Thought
"""
prompt = formatLLMtext_llama3instruct("system", _prompt)
@@ -168,7 +166,7 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
:text=> prompt,
)
)
@show outgoingMsg
_response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
thoughtJsonStr = _response[:response][:text]
thoughtDict = copy(JSON3.read(thoughtJsonStr))