This commit is contained in:
narawat lamaiin
2024-10-14 12:48:55 +07:00
parent 8b67eb1713
commit a35e6e5ba8
2 changed files with 17 additions and 29 deletions

View File

@@ -232,7 +232,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol, Any} where {T<:age
systemmsg =
"""
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for $(a.retailername) store.
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for $(a.retailername)'s online store.
Your goal includes:
1) Get to know the user preferences about wine
2) Help them select the best wines from your inventory that align with their preferences
@@ -363,8 +363,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol, Any} where {T<:age
end
end
println("")
println("--> Yiem decisionMaker() ", @__FILE__, " ", @__LINE__)
println("\n~~~ Yiem decisionMaker() ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict))
# check if LLM recommend wine before checking inventory
@@ -391,9 +390,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol, Any} where {T<:age
showerror(io, e)
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("")
println("Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
println("")
println("\nAttempt $attempt. \nError occurred: $errorMsg\n$st \nPrompt $prompt", @__FILE__, " ", @__LINE__)
end
end
error("DecisionMaker failed to generate a thought ", response)
@@ -546,9 +543,7 @@ function evaluator(config::T1, state::T2
showerror(io, e)
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("")
println("Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
println("")
println("\nAttempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
end
end
error("evaluator failed to generate an evaluation")
@@ -679,9 +674,7 @@ function reflector(config::T1, state::T2)::String where {T1<:AbstractDict, T2<:A
showerror(io, e)
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("")
println("Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
println("")
println("\nAttempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
end
end
error("reflector failed to generate a thought")
@@ -1149,8 +1142,7 @@ function generatechat(a::sommelier)
error("Context: is in text. This is not allowed")
end
println("")
println("--> generatechat() ", @__FILE__, " ", @__LINE__)
println("\n~~~ generatechat() ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict))
# check if LLM recommend wine before checking inventory
@@ -1177,9 +1169,7 @@ function generatechat(a::sommelier)
showerror(io, e)
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("")
println("Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
println("")
println("\nAttempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
end
end
error("generatechat failed to generate an evaluation")
@@ -1235,8 +1225,7 @@ function generatechat(a::companion)
try
response = a.text2textInstructLLM(prompt)
println("")
println("--> generatechat() ", @__FILE__, " ", @__LINE__)
println("\n~~~ generatechat() ", @__FILE__, " ", @__LINE__)
pprintln(response)
responsedict = GeneralUtils.textToDict(response,["Chat"],
@@ -1250,9 +1239,7 @@ function generatechat(a::companion)
showerror(io, e)
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("")
println("Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
println("")
println("\n Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
noise = GeneralUtils.randstrings(3, 5)
end
end
@@ -1308,7 +1295,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
systemmsg =
"""
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for Yiem's online wine store.
Your name is $(a.name). You are a helpful assistant acting as a polite, website-based sommelier for $(a.retailername)'s online store.
Your goal includes:
1) Help the user select the best wines from your inventory that align with the user's preferences
2) Thanks the user when they don't need any further assistance and invite them to comeback next time
@@ -1370,6 +1357,9 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
Q: What did I find in the database?
A: According to the situation, ...
Q: What items are within the user price range?
A: According to the situation, ...
Q: Did I introduce the coffee blend varieties to the user yet?
A: According to the situation, no, I didn't because I have not searched the database yet.
@@ -1431,7 +1421,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
["Understanding", "Q1"],
rightmarker=":", symbolkey=true, lowercasekey=true)
response = "Q1: " * responsedict[:q1]
println("--> generatequestion ", @__FILE__, " ", @__LINE__)
println("\n~~~ generatequestion ", @__FILE__, " ", @__LINE__)
pprintln(response)
return response
catch e
@@ -1439,9 +1429,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
showerror(io, e)
errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println("")
println("Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
println("")
println("\n Attempt $attempt. Error occurred: $errorMsg\n$st ", @__FILE__, " ", @__LINE__)
end
end
error("generatequestion failed to generate a thought ", response)