This commit is contained in:
narawat lamaiin
2024-10-19 10:44:43 +07:00
parent 41d6a281c0
commit 4f1280daa3
3 changed files with 106 additions and 108 deletions

View File

@@ -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)