diff --git a/src/interface.jl b/src/interface.jl index fcb20e5..c575049 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 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) 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 @@ -1422,6 +1422,9 @@ function generatequestion(a, text2textInstructLLM::Function; recent=nothing)::St q_number = count("Q", response) if q_number < 3 error("too few questions only $q_number questions are generated ", @__FILE__, " ", @__LINE__) + # check whether "A1" is in the response, if not error. + elseif !occursin("A1", response) + error("no answer found in the response ", @__FILE__, " ", @__LINE__) end # response = string(split(response, "Please")[1]) # LLM usually add comments which is no need. responsedict = GeneralUtils.textToDict(response, diff --git a/src/llmfunction.jl b/src/llmfunction.jl index f4f6761..2743ef2 100644 --- a/src/llmfunction.jl +++ b/src/llmfunction.jl @@ -289,12 +289,13 @@ 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("~~~ checkinventory order: $input ", @__FILE__, " ", @__LINE__) wineattributes_1 = extractWineAttributes_1(a, input) wineattributes_2 = extractWineAttributes_2(a, input) - inventoryquery = "$wineattributes_1, $wineattributes_2" - println("--> checkinventory input: $inventoryquery ", @__FILE__, " ", @__LINE__) + inventoryquery = "retailer name: $(a.retailername), $wineattributes_1, $wineattributes_2" + println("~~~ checkinventory input: $inventoryquery ", @__FILE__, " ", @__LINE__) + result = SQLLLM.query(inventoryquery, a.executeSQL, a.text2textInstructLLM, addSQLVectorDB=a.addSQLVectorDB, querySQLVectorDB=a.querySQLVectorDB) diff --git a/src/type.jl b/src/type.jl index 6ccfdcd..a19800f 100644 --- a/src/type.jl +++ b/src/type.jl @@ -130,6 +130,7 @@ julia> agent = YiemAgent.bsommelier( mutable struct sommelier <: agent name::String # agent name id::String # agent id + retailername::String tools::Dict maxHistoryMsg::Integer # e.g. 21th and earlier messages will get summarized @@ -160,6 +161,7 @@ function sommelier( ; name::String= "Assistant", id::String= string(uuid4()), + retailername::String= "retailer_name", maxHistoryMsg::Integer= 20, chathistory::Vector{Dict{Symbol, String}} = Vector{Dict{Symbol, String}}(), ) @@ -192,6 +194,7 @@ function sommelier( newAgent = sommelier( name, id, + retailername, tools, maxHistoryMsg, chathistory,