From a35e6e5ba867fe91f0a26c2416b2778113eda597 Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Mon, 14 Oct 2024 12:48:55 +0700 Subject: [PATCH] update --- src/interface.jl | 42 +++++++++++++++--------------------------- src/llmfunction.jl | 4 ++-- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index c575049..fa68014 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -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) diff --git a/src/llmfunction.jl b/src/llmfunction.jl index b388ef6..1da7887 100644 --- a/src/llmfunction.jl +++ b/src/llmfunction.jl @@ -289,7 +289,7 @@ julia> result = checkinventory(agent, input) """ function checkinventory(a::T1, input::T2 )::NamedTuple{(:result, :success, :errormsg), Tuple{String, Bool, Union{String, Nothing}}} where {T1<:agent, T2<:AbstractString} - println("~~~ checkinventory order: $input ", @__FILE__, " ", @__LINE__) + println("\n~~~ checkinventory order: $input ", @__FILE__, " ", @__LINE__) wineattributes_1 = extractWineAttributes_1(a, input) wineattributes_2 = extractWineAttributes_2(a, input) @@ -310,7 +310,7 @@ function checkinventory(a::T1, input::T2 ) ) - println("checkinventory result ", @__FILE__, " ", @__LINE__) + println("\n~~~ checkinventory result ", @__FILE__, " ", @__LINE__) println(result) return (result=result, success=true, errormsg=nothing)