This commit is contained in:
narawat lamaiin
2024-10-15 20:53:11 +07:00
parent 0291a361e8
commit 64efcc79a0

View File

@@ -292,7 +292,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
Third, explain the potential impact each option could bring to the user."
- ENDCONVERSATION which you can use when you believe the user has concluded their interaction, to properly end the conversation with them. Input is "NA".
5) Action_input: input of the action
6) Mentioning_winery: Are there any winery names mentioned in your response? Can be the names of the wineries or "None".
6) Mentioning_winery: Are there any winery mentioned in your response? Can be the names of the wineries or "None".
You should only respond in format as described below:
Understanding: ...
@@ -382,21 +382,12 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
#[WORKING] check whether winery is from agent's memory
mentioned_winery = strip.(split(responsedict[:mentioning_winery], ","))
for i in mentioned_winery
if i != "None" && !occursin(i, timeline)
if i != "None" && i != "" && !occursin(i, timeline)
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
error("Before recommending a wine, ensure it's in your inventory. Check your stock first.")
end
end
# # check if LLM recommend wine before checking inventory
# isMemEmpty = isempty(a.memory[:shortmem])
# if !occursin("None", responsedict[:mentioning_winery]) && isMemEmpty &&
# responsedict[:action_name] != "CHECKINVENTORY"
# errornote = "Note: You can't recommend wines yet. You must check your inventory before recommending wine to the user."
# error("You can't recommend wines yet. You must check your inventory before recommending wines")
# else
if responsedict[:action_name] == "PRESENTBOX" && mentioned_winery == "None"
errornote = "Note: Before recommending a wine, ensure it's in your inventory. Check your stock first."
error("Before recommending a wine, ensure it's in your inventory. Check your stock first.")
@@ -982,10 +973,10 @@ julia>
"""
function think(a::T)::NamedTuple{(:actionname, :result),Tuple{String,String}} where {T<:agent}
a.memory[:recap] = generateSituationReport(a, a.text2textInstructLLM; skiprecent=5)
a.memory[:QandA] = generatequestion(a, a.text2textInstructLLM; recent=5)
a.memory[:recap] = generateSituationReport(a, a.text2textInstructLLM; skiprecent=3)
a.memory[:QandA] = generatequestion(a, a.text2textInstructLLM; recent=3)
thoughtDict = decisionMaker(a; recent=5)
thoughtDict = decisionMaker(a; recent=3)
actionname = thoughtDict[:action_name]
actioninput = thoughtDict[:action_input]
@@ -1090,7 +1081,7 @@ function generatechat(a::sommelier)
You should then respond to the user with:
1) Mentioning_winery: Are there any winery names mentioned in your response? Can be the names of the wineries or "None".
2) Chat: Given the situation, How would you respond to the user in a way that expresses your thoughts while keeping the conversation going smoothly?
2) Chat: Given the situation, how would you respond to the user in a way that expresses your thoughts while keeping the conversation going smoothly?
You should only respond in format as described below:
Mentioning_winery: ...
@@ -1405,6 +1396,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
end
end
errornote = ""
noise = ""
response = nothing # store for show when error msg show up
for attempt in 1:10
@@ -1412,6 +1404,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
Recap: $(a.memory[:recap])
Your recent events: $timeline
$errornote
$noise
"""
_prompt =
@@ -1459,6 +1452,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("\nAttempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
noise = GeneralUtils.randstrings(3, 5)
end
end
error("generatequestion failed to generate a thought ", response)