update
This commit is contained in:
@@ -358,36 +358,36 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
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 format as described below:
|
||||
Thought: ...
|
||||
Wine_name: ...
|
||||
Winery: ...
|
||||
Vintage: ...
|
||||
Region: ...
|
||||
Country: ...
|
||||
Wine_type:
|
||||
Grape_varietal: ...
|
||||
Tasting_notes: ...
|
||||
Wine_price: ...
|
||||
Occasion: ...
|
||||
Food_to_be_paired_with_wine: ...
|
||||
|
||||
Here are some example:
|
||||
User's query: red, Chenin Blanc, Riesling, 20 USD
|
||||
{"reasoning": ..., "winery": "NA", "wine_name": "NA", "vintage": "NA", "region": "NA", "country": "NA", "wine_type": "red, white", "grape_varietal": "Chenin Blanc, Riesling", "tasting_notes": "NA", "wine_price": "0-20", "occasion": "NA", "food_to_be_paired_with_wine": "NA"}
|
||||
You should only respond in format as described below:
|
||||
Thought: ...
|
||||
Wine_name: ...
|
||||
Winery: ...
|
||||
Vintage: ...
|
||||
Region: ...
|
||||
Country: ...
|
||||
Wine_type:
|
||||
Grape_varietal: ...
|
||||
Tasting_notes: ...
|
||||
Wine_price: ...
|
||||
Occasion: ...
|
||||
Food_to_be_paired_with_wine: ...
|
||||
|
||||
Here are some example:
|
||||
User's query: red, Chenin Blanc, Riesling, 20 USD
|
||||
{"reasoning": ..., "winery": "NA", "wine_name": "NA", "vintage": "NA", "region": "NA", "country": "NA", "wine_type": "red, white", "grape_varietal": "Chenin Blanc, Riesling", "tasting_notes": "NA", "wine_price": "0-20", "occasion": "NA", "food_to_be_paired_with_wine": "NA"}
|
||||
|
||||
User's query: Domaine du Collier Saumur Blanc 2019, France, white, Merlot
|
||||
{"reasoning": ..., "winery": "Domaine du Collier", "wine_name": "Saumur Blanc", "vintage": "2019", "region": "Saumur", "country": "France", "wine_type": "white", "grape_varietal": "Merlot", "tasting_notes": "NA", "wine_price": "NA", "occasion": "NA", "food_to_be_paired_with_wine": "NA"}
|
||||
User's query: Domaine du Collier Saumur Blanc 2019, France, white, Merlot
|
||||
{"reasoning": ..., "winery": "Domaine du Collier", "wine_name": "Saumur Blanc", "vintage": "2019", "region": "Saumur", "country": "France", "wine_type": "white", "grape_varietal": "Merlot", "tasting_notes": "NA", "wine_price": "NA", "occasion": "NA", "food_to_be_paired_with_wine": "NA"}
|
||||
|
||||
Let's begin!
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
header = ["Thought:", "Wine_name:", "Winery:", "Vintage:", "Region:", "Country:", "Wine_type:", "Grape_varietal:", "Tasting_notes:", "Wine_price:", "Occasion:", "Food_to_be_paired_with_wine:"]
|
||||
dictkey = ["thought", "wine_name", "winery", "vintage", "region", "country", "wine_type", "grape_varietal", "tasting_notes", "wine_price", "occasion", "food_to_be_paired_with_wine"]
|
||||
errornote = ""
|
||||
errornote = "N/A"
|
||||
|
||||
for attempt in 1:10
|
||||
#[WORKING] I should add generatequestion()
|
||||
#[PENDING] I should add generatequestion()
|
||||
|
||||
if attempt > 1
|
||||
println("\nYiemAgent extractWineAttributes_1() attempt $attempt/10 ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
@@ -396,7 +396,7 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
usermsg =
|
||||
"""
|
||||
User's query: $input
|
||||
$errornote
|
||||
P.S. $errornote
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
@@ -415,8 +415,8 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
checkFlag = false
|
||||
for word in header
|
||||
if !occursin(word, response)
|
||||
errornote = "$word attribute is missing in previous attempts"
|
||||
println("Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
errornote = "In your previous attempts, the $word attribute is missing. Please try again."
|
||||
println("\nYiemAgent extractWineAttributes_1() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
checkFlag = true
|
||||
break
|
||||
end
|
||||
@@ -426,10 +426,12 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
# check whether response has all header
|
||||
detected_kw = GeneralUtils.detect_keyword(header, response)
|
||||
if 0 ∈ values(detected_kw)
|
||||
errornote = "\nYiemAgent extractWineAttributes_1() response does not have all header"
|
||||
errornote = "In your previous attempts, the response does not have all header"
|
||||
println("\nYiemAgent extractWineAttributes_1() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
elseif sum(values(detected_kw)) > length(header)
|
||||
errornote = "\nYiemAgent extractWineAttributes_1() response has duplicated header"
|
||||
errornote = "In your previous attempts, the response has duplicated header"
|
||||
println("\nYiemAgent extractWineAttributes_1() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
responsedict = GeneralUtils.textToDict(response, header;
|
||||
@@ -453,8 +455,8 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
if responsedict[:wine_price] != "NA"
|
||||
# check whether wine_price is in ranged number
|
||||
if !occursin('-', responsedict[:wine_price])
|
||||
errornote = "wine_price must be a range number"
|
||||
println("ERROR YiemAgent extractWineAttributes_1() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
errornote = "In your previous attempt, the 'wine_price' was not set to a ranged number. Please adjust it accordingly."
|
||||
println("\nERROR YiemAgent extractWineAttributes_1() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
checkFlag = true
|
||||
break
|
||||
end
|
||||
@@ -468,8 +470,8 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
end
|
||||
# price range like 100-100 is not good
|
||||
if minprice == maxprice
|
||||
errornote = "wine_price with minimum equals to maximum is not valid"
|
||||
println("ERROR YiemAgent extractWineAttributes_1() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
errornote = "In your previous attempt, you inputted 'wine_price' with a 'minimum' value equaling the 'maximum', which is not valid."
|
||||
println("\nERROR YiemAgent extractWineAttributes_1() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
checkFlag = true
|
||||
break
|
||||
end
|
||||
@@ -631,7 +633,7 @@ function extractWineAttributes_2(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
"""
|
||||
$conversiontable
|
||||
User's query: $input
|
||||
$errornote
|
||||
P.S. $errornote
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
@@ -649,10 +651,12 @@ function extractWineAttributes_2(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
# check whether response has all header
|
||||
detected_kw = GeneralUtils.detect_keyword(header, response)
|
||||
if 0 ∈ values(detected_kw)
|
||||
errornote = "\nYiemAgent extractWineAttributes_2() response does not have all header"
|
||||
errornote = "In your previous attempt does not have all header"
|
||||
println("\nERROR YiemAgent extractWineAttributes_2() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
elseif sum(values(detected_kw)) > length(header)
|
||||
errornote = "\nYiemAgent extractWineAttributes_2() response has duplicated header"
|
||||
errornote = "In your previous attempt has duplicated header"
|
||||
println("\nERROR YiemAgent extractWineAttributes_2() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
|
||||
@@ -664,8 +668,8 @@ function extractWineAttributes_2(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
keyword = Symbol(i * "_keyword") # e.g. sweetness_keyword
|
||||
value = responsedict[keyword]
|
||||
if value != "NA" && !occursin(value, input)
|
||||
errornote = "WARNING. Keyword $keyword: $value does not appear in the input. You must use information from the input only"
|
||||
println("Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
errornote = "In your previous attempt, keyword $keyword: $value does not appear in the input. You must use information from the input only"
|
||||
println("\nERROR YiemAgent extractWineAttributes_2() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
|
||||
@@ -681,7 +685,7 @@ function extractWineAttributes_2(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
if !occursin("keyword", string(k))
|
||||
if v !== "NA" && (!occursin('-', v) || length(v) > 5)
|
||||
errornote = "WARNING: The non-range value {$k: $v} is not allowed. It should be specified in a range format, i.e. min-max."
|
||||
println("Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
println("\nERROR YiemAgent extractWineAttributes_2() Attempt $attempt $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
end
|
||||
@@ -757,7 +761,7 @@ function paraphrase(text2textInstructLLM::Function, text::String)
|
||||
for attempt in 1:10
|
||||
usermsg = """
|
||||
Text: $text
|
||||
$errornote
|
||||
P.S. $errornote
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
|
||||
Reference in New Issue
Block a user