update
This commit is contained in:
@@ -212,8 +212,8 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
|
|||||||
|
|
||||||
systemmsg =
|
systemmsg =
|
||||||
"""
|
"""
|
||||||
You are an website-based polite sommelier working for an online wine store. You are currently talking with the user.
|
You are a website-based, attentive, and polite sommelier working for an online wine store. You are currently talking with the user.
|
||||||
Your task is to help the user choose the best wine from your inventory that matches their tastes.
|
Your task is to help the user choose the best wine from your inventory that matches the user preferences.
|
||||||
|
|
||||||
Definitions:
|
Definitions:
|
||||||
"observation" is result of the preceding immediate action.
|
"observation" is result of the preceding immediate action.
|
||||||
@@ -225,8 +225,8 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
|
|||||||
You MUST follow the following guidelines:
|
You MUST follow the following guidelines:
|
||||||
- Generally speaking, your inventory has some wines from France, the United States, Australia, Spain, and Italy but you won't know which wines are in stock until you check your inventory.
|
- Generally speaking, your inventory has some wines from France, the United States, Australia, Spain, and Italy but you won't know which wines are in stock until you check your inventory.
|
||||||
- Use the "get to know the user's preferences, then check inventory" strategy to help the user, as there are many wines in the inventory.
|
- Use the "get to know the user's preferences, then check inventory" strategy to help the user, as there are many wines in the inventory.
|
||||||
- After recommending wine to the user, ask if there is anything else you can help with, but do not offer any additional services. If the user doesn't need anything else, say thank you and goodbye.
|
- After recommending wines to the user, ask if there is anything else you can help with, but do not offer any extra services. If the user doesn't need anything else, say thank you and goodbye.
|
||||||
- Do not ask the user about wine's flavors
|
- Do not ask the user about wine's flavor e.g. floral, citrusy, nutty or some thing similar.
|
||||||
|
|
||||||
You should follow the following guidelines as you see fit:
|
You should follow the following guidelines as you see fit:
|
||||||
- If the user interrupts, prioritize the user.
|
- If the user interrupts, prioritize the user.
|
||||||
@@ -1000,18 +1000,14 @@ function conversation(a::T, userinput::Dict) where {T<:agent}
|
|||||||
|
|
||||||
if llmCheckInv && actionname != "checkinventory"
|
if llmCheckInv && actionname != "checkinventory"
|
||||||
actionname, result = forceInventoryCheck(a)
|
actionname, result = forceInventoryCheck(a)
|
||||||
if actionname == "CHATBOX"
|
push!(a.memory[:shortmem], Dict(Symbol(actionname)=> result))
|
||||||
a.memory[:chatbox] = result
|
|
||||||
else
|
|
||||||
push!(a.memory[:shortmem], Dict(Symbol(actionname)=> result))
|
|
||||||
end
|
|
||||||
|
|
||||||
# generate chatresponse again because we have force inventory check
|
# generate chatresponse again because we have force inventory check
|
||||||
chatresponse = generatechat(a.memory, a.chathistory, a.text2textInstructLLM)
|
chatresponse = generatechat(a.memory, a.chathistory, a.text2textInstructLLM)
|
||||||
|
|
||||||
else
|
else
|
||||||
if actionname == "CHATBOX"
|
if actionname == "CHATBOX"
|
||||||
a.memory[:chatbox] = result
|
# skip
|
||||||
else
|
else
|
||||||
push!(a.memory[:shortmem], Dict(Symbol(actionname)=> result))
|
push!(a.memory[:shortmem], Dict(Symbol(actionname)=> result))
|
||||||
end
|
end
|
||||||
@@ -1221,8 +1217,8 @@ julia>
|
|||||||
function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::Function)
|
function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::Function)
|
||||||
systemmsg =
|
systemmsg =
|
||||||
"""
|
"""
|
||||||
You are an website-based polite sommelier working for an online wine store.
|
You are a website-based, attentive, and polite sommelier working for an online wine store. You are currently talking with the user.
|
||||||
Your task is to help the user choose the best wine from your inventory that matches their tastes.
|
Your task is to help the user choose the best wine from your inventory that matches the user preferences.
|
||||||
|
|
||||||
At each round of conversation, the user will give you the current situation:
|
At each round of conversation, the user will give you the current situation:
|
||||||
Context: ...
|
Context: ...
|
||||||
@@ -1231,7 +1227,6 @@ function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::F
|
|||||||
|
|
||||||
You must follow the following guidelines:
|
You must follow the following guidelines:
|
||||||
- Your thoughts matter.
|
- Your thoughts matter.
|
||||||
- Do not ask the user about wine's flavors
|
|
||||||
|
|
||||||
You should then respond to the user with:
|
You should then respond to the user with:
|
||||||
- chat: what do you want to say to the user based on the current situation
|
- chat: what do you want to say to the user based on the current situation
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ function extractWineAttributes_1(a::T1, input::T2
|
|||||||
User's query: ...
|
User's query: ...
|
||||||
|
|
||||||
The preference form requires the following information:
|
The preference form requires the following information:
|
||||||
wine_type, price, occasion, food_to_be_paired_with_wine, country, grape_variety, wine_notes.
|
wine_type, price, occasion, food_to_be_paired_with_wine, country, grape_variety, flavors, aromas.
|
||||||
|
|
||||||
You must follow the following guidelines:
|
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.
|
||||||
@@ -345,7 +345,7 @@ function extractWineAttributes_1(a::T1, input::T2
|
|||||||
- occasion: ...
|
- occasion: ...
|
||||||
- food_to_be_paired_with_wine: food that the user 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
|
- country: wine's country of origin
|
||||||
- grape variety: Name of grape used to make wine.
|
- grape variety: a single name of grape used to make wine.
|
||||||
- flavors: Names of items that the wine tastes like.
|
- flavors: Names of items that the wine tastes like.
|
||||||
- aromas: wine's aroma
|
- aromas: wine's aroma
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ function extractWineAttributes_1(a::T1, input::T2
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
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", "grape_variety", "flavors", "aromas"]
|
||||||
|
errornote = ""
|
||||||
for attempt in 1:5
|
for attempt in 1:5
|
||||||
try
|
try
|
||||||
response = a.text2textInstructLLM(prompt)
|
response = a.text2textInstructLLM(prompt)
|
||||||
@@ -396,16 +396,26 @@ function extractWineAttributes_1(a::T1, input::T2
|
|||||||
end
|
end
|
||||||
end
|
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")
|
||||||
|
end
|
||||||
|
|
||||||
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"")
|
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"")
|
||||||
delete!(responsedict, :reasoning)
|
delete!(responsedict, :reasoning)
|
||||||
delete!(responsedict, :tasting_notes)
|
delete!(responsedict, :tasting_notes)
|
||||||
delete!(responsedict, :flavors)
|
delete!(responsedict, :flavors)
|
||||||
delete!(responsedict, :aromas)
|
delete!(responsedict, :aromas)
|
||||||
|
|
||||||
|
# remove (some text)
|
||||||
|
for (k, v) in responsedict
|
||||||
|
_v = replace(v, r"\(.*?\)" => "")
|
||||||
|
responsedict[k] = _v
|
||||||
|
end
|
||||||
|
|
||||||
result = ""
|
result = ""
|
||||||
for (k, v) in responsedict
|
for (k, v) in responsedict
|
||||||
# some time LLM generate text with "(some comment)". this line removes it
|
# 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)
|
if !occursin("NA", v) && v != "" && !occursin("none", v) && !occursin("None", v)
|
||||||
result *= "$k: $v, "
|
result *= "$k: $v, "
|
||||||
end
|
end
|
||||||
@@ -551,6 +561,20 @@ function extractWineAttributes_2(a::T1, input::T2
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# remove (some text)
|
||||||
|
for (k, v) in responsedict
|
||||||
|
_v = replace(v, r"\(.*?\)" => "")
|
||||||
|
responsedict[k] = _v
|
||||||
|
end
|
||||||
|
|
||||||
|
# some time LLM not put integer range
|
||||||
|
for (k, v) in responsedict
|
||||||
|
responsedict[k] = v
|
||||||
|
if length(v) > 5
|
||||||
|
error("non-range is not allowed. $k $v")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# some time LLM says NA-2. Need to convert NA to 1
|
# some time LLM says NA-2. Need to convert NA to 1
|
||||||
for (k, v) in responsedict
|
for (k, v) in responsedict
|
||||||
if occursin("NA", v) && occursin("-", v)
|
if occursin("NA", v) && occursin("-", v)
|
||||||
@@ -562,7 +586,6 @@ function extractWineAttributes_2(a::T1, input::T2
|
|||||||
result = ""
|
result = ""
|
||||||
for (k, v) in responsedict
|
for (k, v) in responsedict
|
||||||
# some time LLM generate text with "(some comment)". this line removes it
|
# some time LLM generate text with "(some comment)". this line removes it
|
||||||
v = replace(v, r"\(.*?\)" => "")
|
|
||||||
if !occursin("NA", v)
|
if !occursin("NA", v)
|
||||||
result *= "$k: $v, "
|
result *= "$k: $v, "
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ end
|
|||||||
main()
|
main()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
I'm having a graduation party this evening. I have unlimited budget. I want a bottle of dry white wine.
|
I'm having a graduation party this evening. I have unlimited budget. I want a bottle of dry red wine.
|
||||||
The party will be casual with no food serving.
|
It will be a casual party with no food serving.
|
||||||
I'm open to suggestion since I have no specific idea about wine other than I like full bodied wine from France.
|
I'm open to suggestion since I have no specific idea about wine other than I like full bodied wine from France.
|
||||||
The latter one seems nice.
|
The latter one seems nice.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user