This commit is contained in:
narawat lamaiin
2024-07-18 12:54:34 +07:00
parent 6e2391e0e3
commit 32530a226d
2 changed files with 21 additions and 19 deletions

View File

@@ -579,7 +579,7 @@ julia>
# Signature
"""
function wineattributes_wordToNumber(a::T1, input::T2
)::Dict where {T1<:agent, T2<:AbstractString}
)::String where {T1<:agent, T2<:AbstractString}
converstiontable =
"""
@@ -617,26 +617,26 @@ function wineattributes_wordToNumber(a::T1, input::T2
At each round of conversation, the user will give you the current situation:
Conversion Table: ...
Query: ...
Last round missing info: some info are missing
You should follow the following guidelines:
- If specific information is unavailable, please use "NA" to indicate this.
- Use converstion table to convert sweetness, acidity, tannin, intensity describing word into an integer.
- Do not generate other comments.
You should then respond to the user with:
You should then respond to the user with the following points:
- wine_type: Can be one of: red, white, sparkling, rose, dessert or fortified
- budget: ...
- occasion: ...
- food_pairing: food that will be served with wine
- country: wine's country of origin
- grape_variety: ...
- sweetness: S where S is an integer of sweetness level
- acidity: A where A is an integer of acidity level
- tannin: T where T is an integer of tannin level
- intensity: I where I is an integer of intensity level
- sweetness: S where S is an integer indicating sweetness level
- acidity: A where A is an integer indicating acidity level
- tannin: T where T is an integer indicating tannin level
- intensity: I where I is an integer indicating intensity level
You should only respond in format as described below:
repeat: repeat the user's query
wine_type: ...
budget: ...
occasion: ...
@@ -650,24 +650,19 @@ function wineattributes_wordToNumber(a::T1, input::T2
Here are some examples:
user: "price < 25, full-bodied white wine with sweetness level 2, low tannin level and medium acidity level, Pizza, France, Riesling"
assistant:
wine_type: white, budget: less than 25, food_pairing: Pizza, country: France, grape_variety: Riesling, sweetness: 2, acidity: 3, tannin: 1, intensity: 5
user: "price < 25, for wedding party, full-bodied white wine with sweetness level 2, low tannin level and medium acidity level, Pizza, France, Riesling"
assistant: repeat: ... \n wine_type: white\n budget: less than 25\n occasion: wedding party\n food_pairing: Pizza\n country: France\n grape_variety: Riesling\n sweetness: 2\n acidity: 3\n tannin: 1\n intensity: 5
user: body=full-bodied, dry, acidity=medium and low tannin
assistant:
wine_type: NA, budget: NA, food_pairing: NA, country: NA, grape_variety: NA, sweetness: 1, acidity: 3, tannin: 1, intensity: 5
assistant: repeat: ... \n wine_type: NA\n budget: NA\n occasion: NA\n food_pairing: NA\n country: NA\n grape_variety: NA\n sweetness: 1\n acidity: 3\n tannin: 1\n intensity: 5
Let's begin!
"""
missinginfo = "None"
usermsg =
"""
Conversion Table: $converstiontable
Query: $input
Last round missing info: $missinginfo
"""
_prompt =
@@ -683,7 +678,7 @@ function wineattributes_wordToNumber(a::T1, input::T2
<|start_header_id|>assistant<|end_header_id|>
"""
attributes = ["wine_type", "budget", "occasion", "food_pairing", "country", "grape_variety", "sweetness", "acidity", "tannin", "intensity"]
attributes = ["repeat", "wine_type", "budget", "occasion", "food_pairing", "country", "grape_variety", "sweetness", "acidity", "tannin", "intensity"]
for attempt in 1:5
try
@@ -691,7 +686,7 @@ function wineattributes_wordToNumber(a::T1, input::T2
responsedict = GeneralUtils.textToDict(response, attributes, rightmarker=":", symbolkey=true)
for i attributes
if length(JSON3.write(responsedict[i])) == 0
if length(JSON3.write(responsedict[Symbol(i)])) == 0
error("$i is empty ", @__LINE__)
end
end
@@ -704,7 +699,14 @@ function wineattributes_wordToNumber(a::T1, input::T2
end
end
result = responsedict[:chat]
result = ""
for (k, v) in responsedict
if k != :repeat && v != "NA"
result *= "$k: $v, "
end
end
result = result[1:end-2] # remove the ending ", "
return result
catch e