This commit is contained in:
narawat lamaiin
2025-03-22 15:34:00 +07:00
parent 5a890860a6
commit 883f581b2a
3 changed files with 35 additions and 25 deletions
+13 -11
View File
@@ -248,7 +248,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
for winename in winenames
if !occursin(winename, chathistory)
println("\n~~~ Yiem decisionMaker() found wines from DB ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
println("\nYiem decisionMaker() found wines from DB ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
d = Dict(
:understanding=> "I understand that the customer is looking for a wine that matches their intention and budget.",
:reasoning=> "I checked the inventory and found wines that match the customer's criteria. I will present the wines to the customer.",
@@ -363,7 +363,7 @@ function decisionMaker(a::T; recent::Integer=5)::Dict{Symbol,Any} where {T<:agen
end
checkFlag == true ? continue : nothing
println("\n~~~ Yiem decisionMaker() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
println("\nYiem decisionMaker() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict))
# check whether an agent recommend wines before checking inventory or recommend wines
@@ -959,8 +959,10 @@ function generatechat(a::sommelier, thoughtDict)
You should only respond in format as described below:
Chat: ...
Here are some examples of response format:
Chat: "I see. Let me think about it. I'll get back to you with my recommendation."
Here are some examples:
Your ongoing conversation with the user: "user> hello, I need a new car\n"
Context: "Car previously found in your inventory: 1) Toyota Camry 2020 2) Honda Civic 2021 3) Ford Mustang 2022"
Chat: "Oh, we have a variety of cars available, including the Toyota Camry 2020, the Honda Civic 2021, and the Ford Mustang 2022. Which one would you like to see?"
Let's begin!
"""
@@ -993,7 +995,7 @@ function generatechat(a::sommelier, thoughtDict)
usermsg = """
Your ongoing conversation with the user: $chathistory
Contex: $context
$context
Your thoughts: $yourthought1
$errornote
"""
@@ -1024,10 +1026,10 @@ function generatechat(a::sommelier, thoughtDict)
# check whether response has all header
detected_kw = GeneralUtils.detect_keyword(header, response)
if sum(values(detected_kw)) < length(header)
errornote = "\nSQL decisionMaker() response does not have all header"
errornote = "\nYiemAgent generatechat() response does not have all header"
continue
elseif sum(values(detected_kw)) > length(header)
errornote = "\nSQL decisionMaker() response has duplicated header"
errornote = "\nnYiemAgent generatechat() response has duplicated header"
continue
end
@@ -1047,7 +1049,7 @@ function generatechat(a::sommelier, thoughtDict)
error("Context: is in text. This is not allowed")
end
println("\n~~~ generatechat() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
println("\ngeneratechat() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict))
# check whether an agent recommend wines before checking inventory or recommend wines
@@ -1366,7 +1368,7 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
response = "Q1: " * responsedict[:q1]
println("\n~~~ generatequestion ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
println("\ngeneratequestion ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
pprintln(response)
return response
catch e
@@ -1460,7 +1462,7 @@ function generateSituationReport(a, text2textInstructLLM::Function; skiprecent::
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
println("\n~~~ generateSituationReport() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
println("\ngenerateSituationReport() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
pprintln(response)
return responsedict
@@ -1514,7 +1516,7 @@ function detectWineryName(a, text)
try
response = a.func[:text2textInstructLLM](prompt)
println("\n~~~ detectWineryName() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
println("\ndetectWineryName() ", Dates.now(), " ", @__FILE__, " ", @__LINE__)
pprintln(response)
# check whether response has all header