This commit is contained in:
narawat lamaiin
2024-08-10 18:02:01 +07:00
parent 9251fbf7cc
commit 07cd336d0a
2 changed files with 21 additions and 11 deletions

View File

@@ -221,13 +221,14 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
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: ...
Context: ... Context: ...
Your Q&A: Your Q&A about the situation
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 your store carries 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 your store carries until you check your inventory.
- All wines in your inventory are always in stock. - All wines in your inventory are always in stock.
- Use the "understand-then-check" inventory strategy to understand the user, as there are many wines in the inventory. - Use the "understand-then-check" inventory strategy to understand the user, as there are many wines in the inventory.
- Do not ask the user about wine's flavor e.g. floral, citrusy, nutty or some thing similar. - Do not ask the user about wine's flavor e.g. floral, citrusy, nutty or some thing similar as these terms cannot be used to search the database.
- After the user chose the wine, congratulate the user and end the conversation politely. Don't offer any extra services. - Once the user has selected their wine, if they dont require any further assistance, use the ENDCONVERSATION function to end the conversation.
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.
@@ -275,6 +276,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
""" """
Your conversation with the user: $chathistory Your conversation with the user: $chathistory
$context $context
Your Q&A: $QandA
$errornote $errornote
""" """
@@ -301,7 +303,7 @@ function decisionMaker(a::T)::Dict{Symbol, Any} where {T<:agent}
# action_name = string(split(responsedict[:action_name], '[')[1]) # action_name = string(split(responsedict[:action_name], '[')[1])
# end # end
if responsedict[:action_name] ["PRESENTBOX", "CHATBOX", "CHECKINVENTORY"] if responsedict[:action_name] ["ENDCONVERSATION", "CHATBOX", "CHECKINVENTORY"]
errornote = "You must use the given functions" errornote = "You must use the given functions"
error("You must use the given functions ", @__FILE__, " ", @__LINE__) error("You must use the given functions ", @__FILE__, " ", @__LINE__)
end end
@@ -1049,7 +1051,7 @@ function think(a::T)::NamedTuple{(:actionname, :result), Tuple{String, String}}
response = response =
if actionname == "CHATBOX" if actionname == "CHATBOX"
(result=actioninput, errormsg=nothing, success=true) (result=actioninput, errormsg=nothing, success=true)
elseif actionname == "PRESENTBOX" elseif actionname == "ENDCONVERSATION"
(result=actioninput, errormsg=nothing, success=true) (result=actioninput, errormsg=nothing, success=true)
# recommendbox(a, actioninput) # recommendbox(a, actioninput)
# (result="Compare and recommend wines to the user, providing reasons why each wine is a suitable match for their specific needs.", errormsg=nothing, success=true) # (result="Compare and recommend wines to the user, providing reasons why each wine is a suitable match for their specific needs.", errormsg=nothing, success=true)
@@ -1243,7 +1245,7 @@ function generatechat(memory::Dict, chathistory::Vector, text2textInstructLLM::F
Context: ... Context: ...
You MUST follow the following guidelines: You MUST follow the following guidelines:
- After the user chose the wine, congratulate the user and end the conversation politely. Don't offer any extra services. - Once the user has selected their wine, congratulate them on their choice. If they dont require any further assistance, politely conclude the conversation without offering additional services.
You should follow the following guidelines: You should follow the following guidelines:
- When recommending wines, compare each option and provide reasons why each one is a suitable match for the user's specific needs. - When recommending wines, compare each option and provide reasons why each one is a suitable match for the user's specific needs.
@@ -1344,11 +1346,14 @@ end
function generatequestion(a, text2textInstructLLM::Function)::String function generatequestion(a, text2textInstructLLM::Function)::String
"""
3) ENDCONVERSATION which you can use to end the conversation with the user. The input is "NA"
"""
systemmsg = systemmsg =
""" """
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.
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: ...
@@ -1356,8 +1361,13 @@ function generatequestion(a, text2textInstructLLM::Function)::String
You must follow the following guidelines: You must follow the following guidelines:
1) Ask at least two questions but no more than five. 1) Ask at least two questions but no more than five.
3) Your question should be specific, self-contained and not require any additional context. 2) Your question should be specific, self-contained and not require any additional context.
4) Do not generate any question or comments at the end. 3) Do not generate any question or comments at the end.
4) Once the user has selected their wine, congratulate them on their choice. If they dont require any further assistance, politely the conversation without offering additional services.
You should follow the following guidelines:
- Do not ask the user about wine's flavor e.g. floral, citrusy, nutty or some thing similar as these terms cannot be used to search the database.
- All wines in your inventory are always in stock.
You should then respond to the user with: You should then respond to the user with:
- Reasoning: State your detailed reasoning of the current situation - Reasoning: State your detailed reasoning of the current situation

View File

@@ -400,17 +400,17 @@ function extractWineAttributes_1(a::T1, input::T2)::String where {T1<:agent, T2<
#[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], "/")) x = length(split(responsedict[:grape_variety], ",")) * length(split(responsedict[:grape_variety], "/"))
if x > 1 if x > 1
errornote = "Note: You can put only one name in grape_variety." errornote = "Note: You can put only one name in grape_variety. Pick one."
error("only a single grape_variety name is allowed") error("only a single grape_variety name is allowed")
end end
x = length(split(responsedict[:country], ",")) * length(split(responsedict[:country], "/")) x = length(split(responsedict[:country], ",")) * length(split(responsedict[:country], "/"))
if x > 1 if x > 1
errornote = "Note: You can put only one name in country." errornote = "Note: You can put only one name in country. Pick one."
error("only a single country name is allowed") error("only a single country name is allowed")
end end
x = length(split(responsedict[:region], ",")) * length(split(responsedict[:region], "/")) x = length(split(responsedict[:region], ",")) * length(split(responsedict[:region], "/"))
if x > 1 if x > 1
errornote = "Note: You can put only one name in region." errornote = "Note: You can put only one name in region. Pick one."
error("only a single region name is allowed") error("only a single region name is allowed")
end end