This commit is contained in:
narawat lamaiin
2024-08-11 01:59:28 +07:00
parent a5f43a0403
commit 38a2f673e9
3 changed files with 43 additions and 23 deletions

View File

@@ -216,7 +216,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
You are a helpful assistant acting as a polite, website-based sommelier for an online wine store. You are a helpful assistant acting as a polite, website-based sommelier for an online wine store.
You are currently talking with the user. You are currently talking with the user.
Your goal is to recommend the best wines from your inventory that match the user's preferences. Your goal is to recommend the best wines from your inventory that match the user's preferences.
You are not responsible for sales. You don't need to do any sale process.
At each round of conversation, you will be given the current situation: At each round of conversation, you will be given the current situation:
Your conversation with the user: ... Your conversation with the user: ...
@@ -1061,7 +1061,7 @@ function think(a::T)::NamedTuple{(:actionname, :result), Tuple{String, String}}
x = "Present the following wines to the user: $actioninput" x = "Present the following wines to the user: $actioninput"
(result=x, errormsg=nothing, success=true) (result=x, errormsg=nothing, success=true)
elseif actionname == "ENDCONVERSATION" elseif actionname == "ENDCONVERSATION"
x = "Thanks the user and end the conversation." x = "Thank the user and conclude the conversation by saying goodbye and inviting them to return next time."
(result=x, errormsg=nothing, success=true) (result=x, errormsg=nothing, success=true)
else else
error("undefined LLM function. Requesting $actionname") error("undefined LLM function. Requesting $actionname")
@@ -1079,7 +1079,8 @@ function think(a::T)::NamedTuple{(:actionname, :result), Tuple{String, String}}
if actionname == "CHATBOX" if actionname == "CHATBOX"
a.memory[:CHATBOX] = result a.memory[:CHATBOX] = result
elseif actionname == "CHECKINVENTORY" elseif actionname == "CHECKINVENTORY"
x = "You have searched the inventory, this is what you found: $result" # x = "You have searched the inventory, this is what you found: $result"
x = result
push!(a.memory[:shortmem], Dict(Symbol(actionname)=> x)) push!(a.memory[:shortmem], Dict(Symbol(actionname)=> x))
elseif actionname == "PRESENTBOX" # tell the generatechat() elseif actionname == "PRESENTBOX" # tell the generatechat()
a.memory[:CHATBOX] = result a.memory[:CHATBOX] = result
@@ -1245,7 +1246,7 @@ function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::F
You are a helpful assistant acting as a polite, website-based sommelier for an online wine store. You are a helpful assistant acting as a polite, website-based sommelier for an online wine store.
You are currently talking with the user. You are currently talking with the user.
Your goal is to recommend the best wines from your inventory that match the user's preferences. Your goal is to recommend the best wines from your inventory that match the user's preferences.
You are not responsible for sales. You don't need to do any sale process.
At each round of conversation, you will be given the current situation: At each round of conversation, you will be given the current situation:
Your conversation with the user: ... Your conversation with the user: ...
@@ -1321,6 +1322,11 @@ function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::F
end end
end end
# check if Context: is in chat
if occursin("Context:", responsedict[:chat])
error("Context: is in text. This is not allowed")
end
println("") println("")
println("--> generatechat() ", @__FILE__, " ", @__LINE__) println("--> generatechat() ", @__FILE__, " ", @__LINE__)
pprintln(responsedict) pprintln(responsedict)
@@ -1359,7 +1365,7 @@ function generatequestion(a, text2textInstructLLM::Function)::String
""" """
You are a helpful assistant acting as a polite, website-based sommelier for an online wine store. You are a helpful assistant acting as a polite, website-based sommelier for an online wine store.
Your task is to self questioning about the current situation. Your task is to self questioning about the current situation.
You are not responsible for sales. You don't need to do any sale process.
At each round of conversation, you will be given the current situation: At each round of conversation, you will be given the current situation:
Your conversation with the user: ... Your conversation with the user: ...

View File

@@ -366,7 +366,8 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
attributes = ["reasoning", "wine_type", "price", "occasion", "food_to_be_paired_with_wine", "country", "region", "grape_variety", "flavors", "aromas"] attributes = ["reasoning", "wine_type", "price", "occasion", "food_to_be_paired_with_wine", "country", "region", "grape_variety", "flavors", "aromas"]
errornote = "" errornote = ""
for attempt in 1:5 maxattempt = 5
for attempt in 1:maxattempt
usermsg = usermsg =
""" """
@@ -398,25 +399,38 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
end end
#[PENDING] check if the following attributes has more than 1 name #[PENDING] check if the following attributes has more than 1 name
x = length(split(responsedict[:grape_variety], ",")) * length(split(responsedict[:grape_variety], "/")) responsedict[:grape_variety] = split(responsedict[:grape_variety], ',')[1]
if x > 1 responsedict[:grape_variety] = split(responsedict[:grape_variety], '/')[1]
errornote = "Note: You can put only one name in grape_variety. Pick one."
error("only a single grape_variety name is allowed") responsedict[:country] = split(responsedict[:country], ',')[1]
end responsedict[:country] = split(responsedict[:country], '/')[1]
x = length(split(responsedict[:country], ",")) * length(split(responsedict[:country], "/"))
if x > 1 responsedict[:region] = split(responsedict[:region], ',')[1]
errornote = "Note: You can put only one name in country. Pick one." responsedict[:region] = split(responsedict[:region], '/')[1]
error("only a single country name is allowed")
end # x = length(split(responsedict[:grape_variety], ",")) * length(split(responsedict[:grape_variety], "/"))
x = length(split(responsedict[:region], ",")) * length(split(responsedict[:region], "/")) # if x > 1
if x > 1 # errornote = "Note: You can put only one name in grape_variety. Pick one."
errornote = "Note: You can put only one name in region. Pick one." # error("only a single grape_variety name is allowed")
error("only a single region name is allowed") # end
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 # check if grape_variety is mentioned in the input
if !occursin("NA", responsedict[:grape_variety]) && !occursin(responsedict[:grape_variety], input) if !occursin("NA", responsedict[:grape_variety]) && !occursin(responsedict[:grape_variety], input)
error("$(responsedict[:grape_variety]) is not mentioned in the input") if attempt < maxattempt
error("$(responsedict[:grape_variety]) is not mentioned in the input")
else
responsedict[:grape_variety] = "NA"
end
end end
responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"") responsedict[:flavors] = replace(responsedict[:flavors], "notes"=>"")

View File

@@ -88,7 +88,7 @@ end
main() main()
""" """
I'm joining a graduation party this evening. I have unlimited budget. I want a bottle of dry red wine. I'm joining a graduation party this evening. I have unlimited budget but I'm ok with wine in all price range. I want a bottle of dry red wine.
Well, it is a small casual party with close friends and no food serving. Well, it is a small casual party with close friends and no food serving.
I'm open to suggestion since I have no specific idea about wine but I like full bodied wine from France. I'm open to suggestion since I have no specific idea about wine but I like full bodied wine from France.