update
This commit is contained in:
@@ -345,6 +345,7 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
- occasion: ...
|
||||
- food_to_be_paired_with_wine: food that the user will be served with wine
|
||||
- country: wine's country of origin
|
||||
- region: wine's region of origin such as Burgundy, Napa Valley
|
||||
- grape variety: a single name of grape used to make wine.
|
||||
- flavors: Names of items that the wine tastes like.
|
||||
- aromas: wine's aroma
|
||||
@@ -356,6 +357,7 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
occasion: ...
|
||||
food_to_be_paired_with_wine: ...
|
||||
country: ...
|
||||
region: ...
|
||||
grape_variety: ...
|
||||
flavors: ...
|
||||
aromas: ...
|
||||
@@ -363,29 +365,29 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
Let's begin!
|
||||
"""
|
||||
|
||||
# chathistory = vectorOfDictToText(a.chathistory)
|
||||
|
||||
usermsg =
|
||||
"""
|
||||
User's query: $input
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
[
|
||||
Dict(:name=> "system", :text=> systemmsg),
|
||||
Dict(:name=> "user", :text=> usermsg)
|
||||
]
|
||||
|
||||
# put in model format
|
||||
prompt = GeneralUtils.formatLLMtext(_prompt, "llama3instruct")
|
||||
prompt *=
|
||||
"""
|
||||
<|start_header_id|>assistant<|end_header_id|>
|
||||
"""
|
||||
|
||||
attributes = ["reasoning", "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", "region", "grape_variety", "flavors", "aromas"]
|
||||
errornote = ""
|
||||
for attempt in 1:5
|
||||
|
||||
usermsg =
|
||||
"""
|
||||
User's query: $input
|
||||
$errornote
|
||||
"""
|
||||
|
||||
_prompt =
|
||||
[
|
||||
Dict(:name=> "system", :text=> systemmsg),
|
||||
Dict(:name=> "user", :text=> usermsg)
|
||||
]
|
||||
|
||||
# put in model format
|
||||
prompt = GeneralUtils.formatLLMtext(_prompt, "llama3instruct")
|
||||
prompt *=
|
||||
"""
|
||||
<|start_header_id|>assistant<|end_header_id|>
|
||||
"""
|
||||
|
||||
try
|
||||
response = a.text2textInstructLLM(prompt)
|
||||
responsedict = GeneralUtils.textToDict(response, attributes, rightmarker=":", symbolkey=true)
|
||||
@@ -397,8 +399,20 @@ function extractWineAttributes_1(a::T1, input::T2
|
||||
end
|
||||
|
||||
#[PENDING] check if grape_variety has more than 1 name
|
||||
if length(split(responsedict[:grape_variety], ",")) > 1
|
||||
error("multiple name in grape_variety is not allowed")
|
||||
x = length(split(responsedict[:grape_variety], ",")) * length(split(responsedict[:grape_variety], "/"))
|
||||
if x > 1
|
||||
errornote = "only a single name in grape_variety is allowed"
|
||||
error("only a single grape_variety name is allowed")
|
||||
end
|
||||
x = length(split(responsedict[:country], ",")) * length(split(responsedict[:country], "/"))
|
||||
if x > 1
|
||||
errornote = "only a single name in country is allowed"
|
||||
error("only a single country name is allowed")
|
||||
end
|
||||
x = length(split(responsedict[:region], ",")) * length(split(responsedict[:region], "/"))
|
||||
if x > 1
|
||||
errornote = "only a single name in region is allowed"
|
||||
error("only a single region name is allowed")
|
||||
end
|
||||
|
||||
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"")
|
||||
|
||||
Reference in New Issue
Block a user