update
This commit is contained in:
@@ -236,13 +236,15 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
- If you found wines in the store's database, they are in stock
|
- If you found wines in the store's database, they are in stock
|
||||||
- Approach each customer with open-ended questions to understand their preferences, budget, and occasion. Once you have these information, you can check your inventory.
|
- Approach each customer with open-ended questions to understand their preferences, budget, and occasion. Once you have these information, you can check your inventory.
|
||||||
- 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. Other wine characteristics useful for CHECKINVENTORY tools are allowed.
|
- 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. Other wine characteristics useful for CHECKINVENTORY tools are allowed.
|
||||||
- Once the user has selected their wine, if you haven't already, ask the user if they need any further assistance. Do not offer any additional services. If the user doesn't need any further assistance, say goodbye and invite them to come back next time.
|
- Once the user has selected their wine, if you haven't already, ask the user whether they need any further assistance. Do not offer any additional services.
|
||||||
|
- If the user is ending the conversation, say goodbye and invite them to come back next time.
|
||||||
- Spicy foods should not be paired with medium and full-bodied red wines.
|
- Spicy foods should not be paired with medium and full-bodied red wines.
|
||||||
- We do not sell organic, sustainability and sulfite wine.
|
- We do not sell organic, sustainability and sulfite wine.
|
||||||
|
- Gift box, gift card, and custom messages are available. Inform the user to contact our sales team.
|
||||||
</Store_policy>
|
</Store_policy>
|
||||||
<Store_guidelines>
|
<Store_guidelines>
|
||||||
- Encourage the customer to explore different options and try new things.
|
- Encourage the customer to explore different options and try new things.
|
||||||
- If you are unable to locate the desired item in the database after multiple attempts, it may not be available in your inventory. In such cases, inform the user that the item is unavailable and suggest an alternative instead.
|
- If you are unable to locate the desired item in the database after 2 attempts, it may not be available in your inventory. In such cases, inform the user that the item is unavailable and suggest an alternative instead.
|
||||||
- Your store carries only wine.
|
- Your store carries only wine.
|
||||||
- Vintage 0 means non-vintage.
|
- Vintage 0 means non-vintage.
|
||||||
</Store_guidelines>
|
</Store_guidelines>
|
||||||
@@ -291,13 +293,13 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
|
|
||||||
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
||||||
errornote = "Your previous attempt has more key points than answer's required key points."
|
errornote = "Your previous attempt has more key points than answer's required key points."
|
||||||
println("\nERROR YiemAgent decisionMaker() $errornote ----not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent decisionMaker() $errornote ----(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
elseif !all(is_requiredKeys_in_responsedictKey)
|
elseif !all(is_requiredKeys_in_responsedictKey)
|
||||||
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
||||||
missingkeys = [requiredKeys[i] for i in zeroind]
|
missingkeys = [requiredKeys[i] for i in zeroind]
|
||||||
errornote = "$missingkeys are missing from your previous response"
|
errornote = "$missingkeys are missing from your previous response"
|
||||||
println("\nERROR YiemAgent decisionMaker() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -334,7 +336,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
|
|
||||||
if responsedict[:action_name] ∉ ["CHATBOX", "CHECKWINE", "PRESENTBOX", "ENDCONVERSATION"]
|
if responsedict[:action_name] ∉ ["CHATBOX", "CHECKWINE", "PRESENTBOX", "ENDCONVERSATION"]
|
||||||
errornote = "Your previous attempt didn't use the given functions"
|
errornote = "Your previous attempt didn't use the given functions"
|
||||||
println("\nERROR YiemAgent decisionMaker() $errornote --not qualify response--> $(responsedict[:action_name])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict[:action_name])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -412,12 +414,11 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
|||||||
println("\nYiemAgent decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nYiemAgent decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
println("\n$response")
|
println("\n$response")
|
||||||
|
|
||||||
#[WORKING]
|
|
||||||
evaluationdict = evaluator(a, timeline, responsedict, context)
|
evaluationdict = evaluator(a, timeline, responsedict, context)
|
||||||
if evaluationdict[:approved] == "no"
|
if evaluationdict[:approved] == "no"
|
||||||
mentor_comment = evaluationdict[:suggestion]
|
mentor_comment = evaluationdict[:suggestion]
|
||||||
errornote = "Your previous attempt was not good enough. Please try again. Here is the mentor's suggestion: $mentor_comment"
|
errornote = "Your previous attempt was not good enough. Please try again. Here is the mentor's suggestion: $mentor_comment"
|
||||||
println("\nERROR YiemAgent decisionMaker() $errornote --not qualify response--> \n$response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> \n$response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -831,26 +832,12 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
|||||||
"action_name" is the name of the action taken, which can be one of the available tool name.
|
"action_name" is the name of the action taken, which can be one of the available tool name.
|
||||||
"action_input" is the input to the action.
|
"action_input" is the input to the action.
|
||||||
</At each round of conversation, you will be given the following information>
|
</At each round of conversation, you will be given the following information>
|
||||||
<Store_policy>
|
|
||||||
- Generally speaking, the store inventory has some wines from France, the United States, Australia, Spain, and Italy, but you won't know exactly until you check your inventory.
|
|
||||||
- If you found wines in the store's database, they are in stock
|
|
||||||
- Approach each customer with open-ended questions to understand their preferences, budget, and occasion. Once you have these information, you can check your inventory.
|
|
||||||
- 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. Other wine characteristics useful for CHECKINVENTORY tools are allowed.
|
|
||||||
- Once the user has selected their wine, if you haven't already, ask the user if they need any further assistance. Do not offer any additional services. If the user doesn't need any further assistance, say goodbye and invite them to come back next time.
|
|
||||||
- Spicy foods should not be paired with medium and full-bodied red wines.
|
|
||||||
- We do not sell organic, sustainability and sulfite wine.
|
|
||||||
</Store_policy>
|
|
||||||
<Store_guidelines>
|
|
||||||
- Encourage the customer to explore different options and try new things.
|
|
||||||
- If you are unable to locate the desired item in the database after multiple attempts, it may not be available in your inventory. In such cases, inform the user that the item is unavailable and suggest an alternative instead.
|
|
||||||
- Your store carries only wine.
|
|
||||||
- Vintage 0 means non-vintage.
|
|
||||||
</Store_guidelines>
|
|
||||||
<You must follow the following policy>
|
<You must follow the following policy>
|
||||||
- Use only infomation provided by the store policy and guidelines as a bedrocks for your response.
|
- Use only infomation provided by the store policy and guidelines as a bedrocks for your response.
|
||||||
</You must follow the following policy>
|
</You must follow the following policy>
|
||||||
<You should follow the following guidelines>
|
<You should follow the following guidelines>
|
||||||
- N/A
|
- The trainee's plan, action_name, and action_input must be logically consistent
|
||||||
|
- The trainee's action_input should be in a proper format as specified by the tools.
|
||||||
</You should follow the following guidelines>
|
</You should follow the following guidelines>
|
||||||
<You should then respond to the user with>
|
<You should then respond to the user with>
|
||||||
1) trajectory_evaluation: Analyze the trajectory of a solution to answer the user's original question.
|
1) trajectory_evaluation: Analyze the trajectory of a solution to answer the user's original question.
|
||||||
@@ -860,16 +847,16 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
|||||||
- Do not generate additional thoughts or actions.
|
- Do not generate additional thoughts or actions.
|
||||||
2) decision_evaluation:
|
2) decision_evaluation:
|
||||||
- Examine how the trainee's decisions align with the store's policies and guidelines before proceeding.
|
- Examine how the trainee's decisions align with the store's policies and guidelines before proceeding.
|
||||||
3) approved: Decide whether to let the trainee proceed or not. Can be "yes" or "no"
|
3) suggestion: Based store policy and guidelines, provide a suggestion for the immediate decision step only.
|
||||||
4) suggestion: Based store policy and guidelines, provide a suggestion for the immediate decision step only.
|
4) approved: Based on suggestion, decide whether to let the trainee proceed with the decision. Can be "yes" or "no"
|
||||||
|
|
||||||
</You should then respond to the user with>
|
</You should then respond to the user with>
|
||||||
<You should only respond in JSON format as described below>
|
<You should only respond in JSON format as described below>
|
||||||
{
|
{
|
||||||
"trajectory_evaluation": "...",
|
"trajectory_evaluation": "...",
|
||||||
"decision_evaluation": "...",
|
"decision_evaluation": "...",
|
||||||
|
"suggestion": "...",
|
||||||
"approved": "...",
|
"approved": "...",
|
||||||
"suggestion": "..."
|
|
||||||
}
|
}
|
||||||
</You should only respond in format as described below>
|
</You should only respond in format as described below>
|
||||||
|
|
||||||
@@ -931,13 +918,13 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
|||||||
|
|
||||||
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
||||||
errornote = "Your previous attempt has more key points than answer's required key points."
|
errornote = "Your previous attempt has more key points than answer's required key points."
|
||||||
println("\nERROR YiemAgent generatechat() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
elseif !all(is_requiredKeys_in_responsedictKey)
|
elseif !all(is_requiredKeys_in_responsedictKey)
|
||||||
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
||||||
missingkeys = [requiredKeys[i] for i in zeroind]
|
missingkeys = [requiredKeys[i] for i in zeroind]
|
||||||
errornote = "$missingkeys are missing from your previous response"
|
errornote = "$missingkeys are missing from your previous response"
|
||||||
println("\nERROR YiemAgent generatechat() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1355,13 +1342,13 @@ function presentbox(a::sommelier, thoughtDict; maxtattempt::Integer=10, recentev
|
|||||||
|
|
||||||
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
||||||
errornote = "Your previous attempt has more key points than answer's required key points."
|
errornote = "Your previous attempt has more key points than answer's required key points."
|
||||||
println("\nERROR YiemAgent presentbox() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent presentbox() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
elseif !all(is_requiredKeys_in_responsedictKey)
|
elseif !all(is_requiredKeys_in_responsedictKey)
|
||||||
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
||||||
missingkeys = [requiredKeys[i] for i in zeroind]
|
missingkeys = [requiredKeys[i] for i in zeroind]
|
||||||
errornote = "$missingkeys are missing from your previous response"
|
errornote = "$missingkeys are missing from your previous response"
|
||||||
println("\nERROR YiemAgent presentbox() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent presentbox() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1536,13 +1523,13 @@ end
|
|||||||
|
|
||||||
# if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
# if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
||||||
# errornote = "Your previous attempt has more key points than answer's required key points."
|
# errornote = "Your previous attempt has more key points than answer's required key points."
|
||||||
# println("\nERROR YiemAgent presentbox() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
# println("\nERROR YiemAgent presentbox() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
# continue
|
# continue
|
||||||
# elseif !all(is_requiredKeys_in_responsedictKey)
|
# elseif !all(is_requiredKeys_in_responsedictKey)
|
||||||
# zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
# zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
||||||
# missingkeys = [requiredKeys[i] for i in zeroind]
|
# missingkeys = [requiredKeys[i] for i in zeroind]
|
||||||
# errornote = "$missingkeys are missing from your previous response"
|
# errornote = "$missingkeys are missing from your previous response"
|
||||||
# println("\nERROR YiemAgent presentbox() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
# println("\nERROR YiemAgent presentbox() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
# continue
|
# continue
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@@ -1736,13 +1723,13 @@ function generatechat(a::sommelier, thoughtDict; maxattempt::Integer=10)
|
|||||||
|
|
||||||
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
|
||||||
errornote = "Your previous attempt has more key points than answer's required key points."
|
errornote = "Your previous attempt has more key points than answer's required key points."
|
||||||
println("\nERROR YiemAgent generatechat() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
elseif !all(is_requiredKeys_in_responsedictKey)
|
elseif !all(is_requiredKeys_in_responsedictKey)
|
||||||
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
|
||||||
missingkeys = [requiredKeys[i] for i in zeroind]
|
missingkeys = [requiredKeys[i] for i in zeroind]
|
||||||
errornote = "$missingkeys are missing from your previous response"
|
errornote = "$missingkeys are missing from your previous response"
|
||||||
println("\nERROR YiemAgent generatechat() $errornote --not qualify response--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export virtualWineUserChatbox, jsoncorrection, checkwine, # recommendbox,
|
|||||||
virtualWineUserRecommendbox, userChatbox, userRecommendbox, extractWineAttributes_1,
|
virtualWineUserRecommendbox, userChatbox, userRecommendbox, extractWineAttributes_1,
|
||||||
extractWineAttributes_2, paraphrase
|
extractWineAttributes_2, paraphrase
|
||||||
|
|
||||||
using HTTP, JSON3, URIs, Random, PrettyPrinting, UUIDs, Dates
|
using HTTP, JSON3, URIs, Random, PrettyPrinting, UUIDs, Dates, DataFrames
|
||||||
using GeneralUtils, SQLLLM
|
using GeneralUtils, SQLLLM
|
||||||
using ..type, ..util
|
using ..type, ..util
|
||||||
|
|
||||||
@@ -316,7 +316,11 @@ function checkwine(a::T1, input::T2; maxattempt::Int=3
|
|||||||
llmFormatName="qwen3")
|
llmFormatName="qwen3")
|
||||||
# check if all of retrieve_attributes appears in textresult
|
# check if all of retrieve_attributes appears in textresult
|
||||||
isin = [occursin(x, textresult) for x in retrieve_attributes]
|
isin = [occursin(x, textresult) for x in retrieve_attributes]
|
||||||
if !all(isin) && !occursin("The resulting table has 0 row", textresult)
|
# check if rawresponse type is DataFrame so that I can check for column
|
||||||
|
if typeof(rawresponse) == DataFrame &&
|
||||||
|
!occursin("The resulting table has 0 row", textresult) &&
|
||||||
|
!all(isin)
|
||||||
|
|
||||||
errornote = "Not all of $retrieve_attributes appear in search result"
|
errornote = "Not all of $retrieve_attributes appear in search result"
|
||||||
println("\nERROR YiemAgent checkwine() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
println("\nERROR YiemAgent checkwine() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
continue
|
continue
|
||||||
@@ -402,10 +406,10 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
|||||||
"wine_name": "N/A",
|
"wine_name": "N/A",
|
||||||
"winery": "N/A",
|
"winery": "N/A",
|
||||||
"vintage": "N/A",
|
"vintage": "N/A",
|
||||||
"region": "Tuscany, Napa Valley",
|
"region": "Tuscany or Napa Valley",
|
||||||
"country": "Italy, United States",
|
"country": "Italy or United States",
|
||||||
"wine_type": "red, white",
|
"wine_type": "red or white",
|
||||||
"grape_varietal": "Chenin Blanc, Riesling",
|
"grape_varietal": "Chenin Blanc or Riesling",
|
||||||
"tasting_notes": "citrus",
|
"tasting_notes": "citrus",
|
||||||
"wine_price_min": "0",
|
"wine_price_min": "0",
|
||||||
"wine_price_max": "20",
|
"wine_price_max": "20",
|
||||||
@@ -804,6 +808,13 @@ function extractWineAttributes_2(a::T1, input::T2)::String where {T1<:agent, T2<
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# delete some key words from responsedict
|
||||||
|
for (k, v) in responsedict
|
||||||
|
if k ∈ [:sweetness_keyword, :acidity_keyword, :tannin_keyword, :intensity_keyword]
|
||||||
|
delete!(responsedict, k)
|
||||||
|
end
|
||||||
|
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
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ function createTimeline(events::T1; eventindex::Union{UnitRange, Nothing}=nothin
|
|||||||
# elseif event[:actionname] == "CHECKINVENTORY" && event[:outcome] === nothing
|
# elseif event[:actionname] == "CHECKINVENTORY" && event[:outcome] === nothing
|
||||||
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: Not done yet.\n"
|
# timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: Not done yet.\n"
|
||||||
# If outcome exists, include it in formatting
|
# If outcome exists, include it in formatting
|
||||||
if event[:actionname] == "CHECKINVENTORY"
|
if event[:actionname] == "CHECKWINE"
|
||||||
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:outcome])\n"
|
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput]), observation: $(event[:outcome])\n"
|
||||||
else
|
else
|
||||||
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput])\n"
|
timeline *= "Event_$i $(event[:subject])> action_name: $(event[:actionname]), action_input: $(event[:actioninput])\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user