update
This commit is contained in:
@@ -324,32 +324,33 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
|
||||
systemmsg =
|
||||
"""
|
||||
As an helpful sommelier, your task is to fill out the user's preference form by copying the corresponding words from the user's query.
|
||||
As an helpful sommelier, your task is to fill out the user's preference form based on the corresponding words from the user's query.
|
||||
|
||||
At each round of conversation, the user will give you the current situation:
|
||||
User query: ...
|
||||
User's query: ...
|
||||
|
||||
The preference form requires the following information:
|
||||
wine_type, price, occasion, food_to_be_paired_with_wine, country, grape_variety, wine_notes.
|
||||
|
||||
You must follow the following guidelines:
|
||||
1) If specific information required in the preference form is not available in the query, use '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:
|
||||
- wine_type: Can be one of: red, white, sparkling, rose, dessert or fortified
|
||||
- reasoning: State your understanding of the current situation
|
||||
- wine_type: Can be one of: "red", "white", "sparkling", "rose", "dessert" or "fortified"
|
||||
- price: Must be an integer representing the cost of the wine.
|
||||
|
||||
- occasion: ...
|
||||
- food_to_be_paired_with_wine: food that will be served with wine
|
||||
- food_to_be_paired_with_wine: food that the user will be served with wine
|
||||
- country: wine's country of origin
|
||||
- grape variety: Name of grape used to make wine.
|
||||
- flavors: wine's flavor
|
||||
- flavors: Names of items that the wine tastes like.
|
||||
- aromas: wine's aroma
|
||||
|
||||
You should only respond in the form as described below:
|
||||
reasoning: ...
|
||||
wine_type: ...
|
||||
price: ...
|
||||
occasion: ...
|
||||
@@ -362,9 +363,11 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
# chathistory = vectorOfDictToText(a.chathistory)
|
||||
|
||||
usermsg =
|
||||
"""
|
||||
User query: $input
|
||||
User's query: $input
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
@@ -380,7 +383,7 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
<|start_header_id|>assistant<|end_header_id|>
|
||||
"""
|
||||
|
||||
attributes = ["wine_type", "price", "occasion", "food_to_be_paired_with_wine", "country", "grape_variety", "flavors", "aromas"]
|
||||
attributes = ["reasoning", "wine_type", "price", "occasion", "food_to_be_paired_with_wine", "country", "grape_variety", "flavors", "aromas"]
|
||||
|
||||
for attempt in 1:5
|
||||
try
|
||||
@@ -393,21 +396,23 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
end
|
||||
end
|
||||
|
||||
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"") #BUG no method matching
|
||||
responsedict[:tasting_notes] = responsedict[:flavors]
|
||||
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"")
|
||||
delete!(responsedict, :reasoning)
|
||||
delete!(responsedict, :tasting_notes)
|
||||
delete!(responsedict, :flavors)
|
||||
delete!(responsedict, :aromas)
|
||||
|
||||
result = ""
|
||||
for (k, v) in responsedict
|
||||
if !occursin("NA", v) && v != ""
|
||||
# some time LLM generate text with "(some comment)". this line removes it
|
||||
v = replace(v, r"\(.*?\)" => "")
|
||||
if !occursin("NA", v) && v != "" && !occursin("none", v) && !occursin("None", v)
|
||||
result *= "$k: $v, "
|
||||
end
|
||||
end
|
||||
|
||||
#[PENDING] remove halucination. "highend dry white wine" --> "wine_type: white, occasion: special occasion, food_to_be_paired_with_wine: seafood, fish, country: France, Italy, USA, grape_variety: Chardonnay, Sauvignon Blanc, Pinot Grigio\nwine_notes: citrus, green apple, floral"
|
||||
|
||||
|
||||
result = result[1:end-2] # remove the ending ", "
|
||||
|
||||
return result
|
||||
@@ -431,7 +436,7 @@ end
|
||||
function extractWineAttributes_2(a::T1, input::T2
|
||||
)::String where {T1<:agent, T2<:AbstractString}
|
||||
|
||||
converstiontable =
|
||||
conversiontable =
|
||||
"""
|
||||
Conversion Table:
|
||||
Intensity level:
|
||||
@@ -460,25 +465,27 @@ function extractWineAttributes_2(a::T1, input::T2
|
||||
4 to 5: May correspond to "high acidity" or a similar description.
|
||||
"""
|
||||
|
||||
# chathistory = vectorOfDictToText(a.chathistory)
|
||||
|
||||
systemmsg =
|
||||
"""
|
||||
As an helpful sommelier, your task is to fill the user's preference form based on the user query.
|
||||
As an helpful sommelier, your task is to fill out the user's preference form based on the corresponding words from the user's query.
|
||||
|
||||
At each round of conversation, the user will give you the current situation:
|
||||
Conversion Table: ...
|
||||
User query: ...
|
||||
User's query: ...
|
||||
|
||||
The preference form requires the following information:
|
||||
sweetness, acidity, tannin, intensity
|
||||
|
||||
You must follow the following guidelines:
|
||||
1) If specific information required in the preference form is not available in the query, use '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:
|
||||
- repeat: State the user query
|
||||
- reasoning: State your understanding of the current situation
|
||||
- sweetness: S where S are integers represent the range of sweetness levels
|
||||
Example: 1-2
|
||||
- acidity: D where D are integers represent the range of acidity level
|
||||
@@ -487,21 +494,25 @@ function extractWineAttributes_2(a::T1, input::T2
|
||||
Example: 1-3
|
||||
- intensity: I where I are integers represent the range of intensity level
|
||||
Example: 2-4
|
||||
- notes: Anything you want to add
|
||||
|
||||
You should only respond in the form as described below:
|
||||
repeat: ...
|
||||
reasoning: ...
|
||||
sweetness: ...
|
||||
acidity: ...
|
||||
tannin: ...
|
||||
intensity: ...
|
||||
notes: ...
|
||||
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
# chathistory = vectorOfDictToText(a.chathistory)
|
||||
|
||||
usermsg =
|
||||
"""
|
||||
Conversion Table: $converstiontable
|
||||
User query: $input
|
||||
$conversiontable
|
||||
User's query: $input
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
@@ -517,7 +528,7 @@ function extractWineAttributes_2(a::T1, input::T2
|
||||
<|start_header_id|>assistant<|end_header_id|>
|
||||
"""
|
||||
|
||||
attributes = ["sweetness", "acidity", "tannin", "intensity"]
|
||||
attributes = ["reasoning", "sweetness", "acidity", "tannin", "intensity", "notes"]
|
||||
|
||||
for attempt in 1:5
|
||||
try
|
||||
@@ -530,6 +541,9 @@ function extractWineAttributes_2(a::T1, input::T2
|
||||
end
|
||||
end
|
||||
|
||||
delete!(responsedict, :reasoning)
|
||||
delete!(responsedict, :notes) # LLM traps. so it can add useless info here like comments.
|
||||
|
||||
# some time LLM think the user mentioning acidity and tannin but actually didn't
|
||||
for (k, v) in responsedict
|
||||
if k ∈ [:acidity, :tannin] && !occursin(string(k), input)
|
||||
@@ -545,9 +559,10 @@ function extractWineAttributes_2(a::T1, input::T2
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
result = ""
|
||||
for (k, v) in responsedict
|
||||
# some time LLM generate text with "(some comment)". this line removes it
|
||||
v = replace(v, r"\(.*?\)" => "")
|
||||
if !occursin("NA", v)
|
||||
result *= "$k: $v, "
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user