update
This commit is contained in:
@@ -125,7 +125,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
|
||||
systemmsg =
|
||||
"""
|
||||
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for $(a.retailername)'s online store.
|
||||
Your name is $(a.name). You are a helpful English-speaking assistant, acting as a polite, website-based sommelier for $(a.retailername)'s online store.
|
||||
Your goal includes:
|
||||
1) Get to know the user preferences about wine
|
||||
2) Help them select the best wines from your inventory that align with their preferences
|
||||
@@ -167,7 +167,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
- CHATBOX which you can use to talk with the user. The input is your intentions for the dialogue. Be specific.
|
||||
- CHECKINVENTORY which you can use to check info about wine in your inventory. The input is a search term in verbal English.
|
||||
Good query example: black car, a stereo, 200 mile range, electric motor.
|
||||
- PRESENTBOX which you can use to introduce / suggest / recommend a wine label from the inventory to the user when it hasn't been introduced before. Not for general conversation nor follow up conversation.
|
||||
- PRESENTBOX which you can use to introduce wine brand (e.g. Domaine du Collier) from your inventory to the user when it hasn't been introduced before.
|
||||
The input is instructions on how you want the presentation to be conducted.
|
||||
Here are some input examples,
|
||||
"First, provide detailed introductions of Zena Crown, Schrader Cabernet Sauvignon.
|
||||
@@ -266,18 +266,51 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
|
||||
|
||||
# check whether an agent recommend wines before checking inventory or
|
||||
# recommend wines outside its inventory
|
||||
mentioned_brand = strip.(split(responsedict[:mentioned_brand], ","))
|
||||
for i in mentioned_brand
|
||||
if i != "None" && i != "" && (!occursin(i, timeline) || !occursin(i, shortmem)) &&
|
||||
responsedict[:action_name] != "CHECKINVENTORY" # OK if the agent is checking inventory
|
||||
|
||||
mentioned_brand = responsedict[:mentioned_brand]
|
||||
if mentioned_brand != "None"
|
||||
mentioned_brand = strip.(split(responsedict[:mentioned_brand], ","))
|
||||
|
||||
isWineInTimeline = false
|
||||
for i in mentioned_brand
|
||||
isWineInTimeline = occursin(i, timeline)
|
||||
if !isWineInTimeline
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
isWineInShortmem = false
|
||||
for i in mentioned_brand
|
||||
isWineInShortmem = occursin(i, shortmem)
|
||||
if !isWineInShortmem
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if responsedict[:action_name] != "CHATBOX" && !isWineInShortmem
|
||||
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
|
||||
error("Before recommending a wine, ensure it's in your inventory. Check your stock first.")
|
||||
elseif responsedict[:action_name] != "CHATBOX" && !isWineInTimeline && isWineInShortmem
|
||||
errornote = "Note: You should introduce the wines to the user before taling about them."
|
||||
error("You should introduce the wines to the user before taling about them.")
|
||||
end
|
||||
|
||||
if responsedict[:action_name] == "PRESENTBOX" && !isWineInShortmem
|
||||
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
|
||||
error("Before recommending a wine, ensure it's in your inventory. Check your stock first.")
|
||||
elseif responsedict[:action_name] == "PRESENTBOX" && !isWineInTimeline
|
||||
errornote = "Note: You already presented these wines."
|
||||
error("You already presented these wines.")
|
||||
end
|
||||
else
|
||||
if responsedict[:action_name] == "PRESENTBOX"
|
||||
errornote = "Note: You don't have wines to present."
|
||||
error("You don't have wines to present.")
|
||||
end
|
||||
end
|
||||
if responsedict[:action_name] == "PRESENTBOX" && mentioned_brand == "None"
|
||||
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
|
||||
error("Before recommending a wine, ensure it's in your inventory. Check your stock first.")
|
||||
|
||||
if occursin("--|", response)
|
||||
errornote = "Note: tables are not allowed. Do not include them your response."
|
||||
error("your response contain tables which is not allowed.")
|
||||
end
|
||||
|
||||
delete!(responsedict, :mentioned_brand)
|
||||
@@ -499,7 +532,7 @@ function reflector(config::T1, state::T2)::String where {T1<:AbstractDict,T2<:Ab
|
||||
"observation_4": "I found the following wines in our stock: \n{\n 1: El Enemigo Cabernet Franc 2019\n2: Tantara Chardonnay 2017\n\n}\n",
|
||||
|
||||
"thought_5": "Now that I have a list of potential wines, I need to know more about the customer's taste preferences.",
|
||||
"action_5": {"name": "CHATBOX", "input": "What type of wine characteristics are you looking for? (e.g. t.e.g. tannin level, sweetness, intensity, acidity)"},
|
||||
"action_5": {"name": "CHATBOX", "input": "What type of wine characteristics are you looking for? (e.g. tannin level, sweetness, intensity, acidity)"},
|
||||
"observation_5": "I like full-bodied red wine with low tannin.",
|
||||
|
||||
"thought_6": "Now that I have more information about the customer's preferences, it's time to make a recommendation.",
|
||||
@@ -811,7 +844,7 @@ julia>
|
||||
function generatechat(a::sommelier)
|
||||
systemmsg =
|
||||
"""
|
||||
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for an online wine store.
|
||||
Your name is $(a.name). You are a helpful English-speaking assistant, acting as a polite, website-based sommelier for an online wine store.
|
||||
You are currently talking with the user.
|
||||
Your goal includes:
|
||||
1) Help the user select the best wines from your inventory that align with the user's preferences.
|
||||
@@ -918,7 +951,7 @@ function generatechat(a::sommelier)
|
||||
# recommend wines outside its inventory
|
||||
mentioned_brand = strip.(split(responsedict[:mentioned_brand], ","))
|
||||
for i in mentioned_brand
|
||||
if i != "None" && i != "" && (!occursin(i, timeline) || !occursin(i, shortmem)) &&
|
||||
if i != "None" && i != "" && (!occursin(i, timeline) || !occursin(i, context)) &&
|
||||
responsedict[:action_name] != "CHECKINVENTORY" # OK if the agent is checking inventory
|
||||
|
||||
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
|
||||
@@ -1017,7 +1050,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
||||
|
||||
systemmsg =
|
||||
"""
|
||||
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for $(a.retailername)'s online store.
|
||||
Your name is $(a.name). You are a helpful English-speaking assistant, acting as a polite, website-based sommelier for $(a.retailername)'s online store.
|
||||
Your goal includes:
|
||||
1) Help the user select the best wines from your inventory that align with the user's preferences
|
||||
2) Thanks the user when they don't need any further assistance and invite them to comeback next time
|
||||
@@ -1091,8 +1124,8 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
|
||||
Q: Do I have them in stock?
|
||||
A: According to the situation, ...
|
||||
|
||||
Q: Did I introduce the coffee blend varieties to the user yet?
|
||||
A: According to the situation, No, because I haven't checked the inventory yet.
|
||||
Q: Did I introduce them to the user already?
|
||||
A: According to the situation, No.
|
||||
|
||||
Q: Am I certain about the information I'm going to share with the user, or should I verify the information first?
|
||||
A: According to the situation, ...
|
||||
|
||||
@@ -349,39 +349,58 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
wine_type, price, occasion, food_to_be_paired_with_wine, region, country, grape_variety, flavors, aromas.
|
||||
|
||||
You must follow the following guidelines:
|
||||
1) If specific information required in the preference form is not available in the query or there isn't any, mark with 'NA' to indicate this.
|
||||
1) If specific information required in the preference form is not available in the query or there isn't any, mark with "NA" to indicate this.
|
||||
Additionally, words like 'any' or 'unlimited' mean no information is available.
|
||||
2) Use the conversion table to convert the descriptive word level of sweetness, intensity, tannin, and acidity into a corresponding integer.
|
||||
3) Do not generate other comments.
|
||||
|
||||
You should then respond to the user with the following points:
|
||||
- reasoning: state your understanding of the current situation
|
||||
- wine_type: can be one of: "red", "white", "sparkling", "rose", "dessert" or "fortified"
|
||||
- price: price of wine. For example, up to 100, less than 100, 20 to 100, 30-79.95
|
||||
- occasion: ...
|
||||
- food_to_be_paired_with_wine: food that the user will be served with the wine
|
||||
- wine_name: name of the wine
|
||||
- winery: name of the winery
|
||||
- vintage: the year of the wine
|
||||
- region: a region in a country where the wine is produced, such as Burgundy, Napa Valley, etc
|
||||
- country: a country where the wine is produced. Can be "Austria", "Australia", "France", "Germany", "Italy", "Portugal", "Spain", "United States"
|
||||
- wine_type: can be one of: "red", "white", "sparkling", "rose", "dessert" or "fortified"
|
||||
- grape_variety: the name of the primary grape used to make the wine
|
||||
- flavors: names of items that the wine tastes like, such as citrus, lime, etc
|
||||
- aromas: the wine's aromas, such as fruity, floral, etc
|
||||
- tasting_notes: a brief description of the wine's taste, such as "butter", "oak", "fruity", etc
|
||||
- wine_price: price of wine. For example, up to 100, less than 100, 20 to 100, 30-79.95
|
||||
- occasion: the occasion the user is having the wine for
|
||||
- food_to_be_paired_with_wine: food that the user will be served with the wine such as poultry, fish, steak, etc
|
||||
|
||||
|
||||
You should only respond in the form as described below:
|
||||
reasoning: ...
|
||||
winery: ...
|
||||
wine_name: ...
|
||||
vintage: ...
|
||||
region: ...
|
||||
country: ...
|
||||
wine_type: ...
|
||||
grape_variety: ...
|
||||
tasting_notes: ...
|
||||
wine_price: ...
|
||||
occasion: ...
|
||||
food_to_be_paired_with_wine: ...
|
||||
region: ...
|
||||
country: ...
|
||||
grape_variety: ...
|
||||
flavors: ...
|
||||
aromas: ...
|
||||
|
||||
Here are some example:
|
||||
reasoning: ...
|
||||
winery: Domaine du Collier
|
||||
wine_name: Saumur Blanc
|
||||
vintage: 2019
|
||||
region: Saumur
|
||||
country: France
|
||||
wine_type: white
|
||||
grape_variety: Chenin Blanc
|
||||
tasting_notes: NA
|
||||
wine_price: 109
|
||||
occasion: NA
|
||||
food_to_be_paired_with_wine: NA
|
||||
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
attributes = ["reasoning", "wine_type", "wine_price", "occasion", "food_to_be_paired_with_wine", "region", "country", "grape_variety", "flavors", "aromas"]
|
||||
attributes = ["reasoning", "winery", "wine_name", "vintage", "region", "country", "wine_type", "grape_variety", "tasting_notes", "wine_price", "occasion", "food_to_be_paired_with_wine"]
|
||||
errornote = ""
|
||||
maxattempt = 5
|
||||
for attempt in 1:maxattempt
|
||||
@@ -434,27 +453,11 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
|
||||
responsedict[:region] = split(responsedict[:region], ',')[1]
|
||||
responsedict[:region] = split(responsedict[:region], '/')[1]
|
||||
|
||||
# x = length(split(responsedict[:grape_variety], ",")) * length(split(responsedict[:grape_variety], "/"))
|
||||
# if x > 1
|
||||
# errornote = "Note: You can put only one name in grape_variety. Pick one."
|
||||
# error("only a single grape_variety name is allowed")
|
||||
# end
|
||||
# x = length(split(responsedict[:country], ",")) * length(split(responsedict[:country], "/"))
|
||||
# if x > 1
|
||||
# errornote = "Note: You can put only one name in country. Pick one."
|
||||
# error("only a single country name is allowed")
|
||||
# end
|
||||
# x = length(split(responsedict[:region], ",")) * length(split(responsedict[:region], "/"))
|
||||
# if x > 1
|
||||
# errornote = "Note: You can put only one name in region. Pick one."
|
||||
# error("only a single region name is allowed")
|
||||
# end
|
||||
|
||||
# check if grape_variety is mentioned in the input
|
||||
if !occursin("NA", responsedict[:grape_variety]) && !occursin(responsedict[:grape_variety], input)
|
||||
if attempt < maxattempt
|
||||
errornote = "$(responsedict[:grape_variety]) is not mentioned in the user query, you must only use the info from the query.."
|
||||
errornote = "$(responsedict[:grape_variety]) is not mentioned in the user query, you must only use the info from the query."
|
||||
error("$(responsedict[:grape_variety]) is not mentioned in the user query, you must only use the info from the query.")
|
||||
else
|
||||
responsedict[:grape_variety] = "NA"
|
||||
@@ -471,12 +474,9 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
end
|
||||
end
|
||||
|
||||
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"")
|
||||
# delete!(responsedict, :region)
|
||||
delete!(responsedict, :reasoning)
|
||||
delete!(responsedict, :tasting_notes)
|
||||
delete!(responsedict, :flavors)
|
||||
delete!(responsedict, :aromas)
|
||||
# delete!(responsedict, :tasting_notes)
|
||||
# delete!(responsedict, :price)
|
||||
delete!(responsedict, :occasion)
|
||||
delete!(responsedict, :food_to_be_paired_with_wine)
|
||||
|
||||
Reference in New Issue
Block a user