update
This commit is contained in:
+58
-41
@@ -290,46 +290,62 @@ function checkwine(a::T1, input::T2; maxattempt::Int=3
|
||||
wineattributes_2 = extractWineAttributes_2(a, input)
|
||||
|
||||
# placeholder
|
||||
textresult = nothing
|
||||
rawresponse = nothing
|
||||
# textresult = nothing
|
||||
# rawresponse = nothing
|
||||
|
||||
for i in 1:maxattempt
|
||||
# for i in 1:maxattempt
|
||||
|
||||
#CHANGE if you want to add retailer name
|
||||
# _inventoryquery = "retailer name: $(a.retailername), $wineattributes_1, $wineattributes_2"
|
||||
_inventoryquery = "$wineattributes_1, $wineattributes_2"
|
||||
# #CHANGE if you want to add retailer name
|
||||
# # _inventoryquery = "retailer name: $(a.retailername), $wineattributes_1, $wineattributes_2"
|
||||
# _inventoryquery = "$wineattributes_1, $wineattributes_2"
|
||||
|
||||
retrieve_attributes = ["winery", "wine_name", "wine_id", "vintage", "region", "country", "wine_type", "grape", "serving_temperature", "sweetness", "intensity", "tannin", "acidity", "tasting_notes", "price", "currency"]
|
||||
inventoryquery = "Retrieves $retrieve_attributes of wines that match the following criteria - {$_inventoryquery}"
|
||||
println("\ncheckinventory input: $inventoryquery ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# add suppport for similarSQLVectorDB
|
||||
#WORKING
|
||||
textresult, rawresponse = SQLLLM.query(
|
||||
inventoryquery,
|
||||
a.context.executeSQL,
|
||||
a.context.text2textInstructLLM;
|
||||
insertSQLVectorDB=a.context.insertSQLVectorDB,
|
||||
similarSQLVectorDB=a.context.similarSQLVectorDB,
|
||||
llmFormatName="qwen3")
|
||||
error(5555)
|
||||
# check if all of retrieve_attributes appears in textresult
|
||||
isin = [occursin(x, textresult) for x in retrieve_attributes]
|
||||
# check if rawresponse type is DataFrame so that I can check for column
|
||||
if typeof(rawresponse) == DataFrame &&
|
||||
!occursin("The resulting table has 0 row", textresult) &&
|
||||
!all(isin)
|
||||
|
||||
errornote = "Not all of $retrieve_attributes appear in search result"
|
||||
println("\nERROR YiemAgent checkwine() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
println("\ncheckinventory result ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
println(textresult)
|
||||
# retrieve_attributes = ["winery", "wine_name", "wine_id", "vintage", "region", "country", "wine_type", "grape", "serving_temperature", "sweetness", "intensity", "tannin", "acidity", "tasting_notes", "price", "currency"]
|
||||
# inventoryquery = "Retrieves $retrieve_attributes of wines that match the following criteria - {$_inventoryquery}"
|
||||
# println("\ncheckinventory input: $inventoryquery ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# # add suppport for similarSQLVectorDB
|
||||
# textresult, result_raw = SQLLLM.query(
|
||||
# inventoryquery,
|
||||
# a.context.executeSQL,
|
||||
# a.context.text2textInstructLLM;
|
||||
# insertSQLVectorDB=a.context.insertSQLVectorDB,
|
||||
# similarSQLVectorDB=a.context.similarSQLVectorDB,
|
||||
# llmFormatName="qwen3")
|
||||
|
||||
return (result=textresult, rawresponse=rawresponse, success=true, errormsg=nothing)
|
||||
# # check if all of retrieve_attributes appears in textresult
|
||||
# isin = [occursin(x, textresult) for x in retrieve_attributes]
|
||||
# # check if rawresponse type is DataFrame so that I can check for column
|
||||
# if typeof(result_raw) == DataFrame &&
|
||||
# !occursin("The resulting table has 0 row", textresult) &&
|
||||
# !all(isin)
|
||||
|
||||
# errornote = "Not all of $retrieve_attributes appear in search result"
|
||||
# println("\nERROR YiemAgent checkwine() $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# continue
|
||||
# else
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
|
||||
#CHANGE if you want to add retailer name
|
||||
# _inventoryquery = "retailer name: $(a.retailername), $wineattributes_1, $wineattributes_2"
|
||||
retrieve_attributes = ["winery", "wine_name", "wine_id", "vintage", "region", "country", "wine_type", "grape", "serving_temperature", "sweetness", "intensity", "tannin", "acidity", "tasting_notes", "price", "currency"]
|
||||
_inventoryquery = "$wineattributes_1, $wineattributes_2"
|
||||
inventoryquery = "Retrieves $retrieve_attributes of wines that match the following criteria - {$_inventoryquery}"
|
||||
println("\ncheckinventory input: $inventoryquery ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# add suppport for similarSQLVectorDB
|
||||
textresult, result_raw = SQLLLM.query(
|
||||
inventoryquery,
|
||||
a.context.executeSQL,
|
||||
a.context.text2textInstructLLM;
|
||||
insertSQLVectorDB=a.context.insertSQLVectorDB,
|
||||
similarSQLVectorDB=a.context.similarSQLVectorDB,
|
||||
llmFormatName="qwen3")
|
||||
# println("\n--- YiemAgent checkwine() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# println(textresult)
|
||||
# println(result_raw)
|
||||
# println("---")
|
||||
|
||||
return (result_str=textresult, result_raw=result_raw, success=true, errormsg=nothing)
|
||||
end
|
||||
|
||||
|
||||
@@ -466,13 +482,13 @@ function extractWineAttributes_1(a::T1, input::T2; maxattempt=10
|
||||
responsedict = nothing
|
||||
try
|
||||
_responsedict = JSON.parse(response)
|
||||
responsedict = GeneralUtils.dictify(_responsedict, keytype=String)
|
||||
responsedict = GeneralUtils.dictify(_responsedict; keytype=String, sort_order=requiredKeys)
|
||||
catch
|
||||
println("\nERROR YiemAgent extractWineAttributes_1() failed to parse response: $response", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
# check whether all answer's key points are in responsedict
|
||||
ispass, errormsg = checkAgentResponse_JSON(responsedict, requiredKeys)
|
||||
ispass, errormsg = GeneralUtils.checkAgentResponse_JSON(responsedict, requiredKeys)
|
||||
if !ispass
|
||||
errornote = errormsg
|
||||
println("\nERROR YiemAgent extractWineAttributes_1() $errornote --(not qualify response)> $responsedict", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
||||
@@ -659,13 +675,14 @@ function extractWineAttributes_2(a::T1, input::T2)::String where {T1<:agent, T2<
|
||||
responsedict = nothing
|
||||
try
|
||||
_responsedict = JSON.parse(response)
|
||||
responsedict = GeneralUtils.dictify(_responsedict, keytype=String)
|
||||
responsedict = GeneralUtils.dictify(_responsedict; keytype=String, sort_order=requiredKeys)
|
||||
catch
|
||||
println("\nERROR YiemAgent extractWineAttributes_2() failed to parse response: $response", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
end
|
||||
|
||||
# check whether all answer's key points are in responsedict
|
||||
ispass, errormsg = checkAgentResponse_JSON(responsedict, requiredKeys)
|
||||
ispass, errormsg = GeneralUtils.checkAgentResponse_JSON(responsedict, requiredKeys)
|
||||
if !ispass
|
||||
errornote = errormsg
|
||||
println("\nERROR YiemAgent extractWineAttributes_2() $errornote --(not qualify response)> $responsedict", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
||||
@@ -919,7 +936,7 @@ end
|
||||
# "thought" is step-by-step reasoning about the current situation.
|
||||
# "plan" is what to do to complete the task from the current situation.
|
||||
# “action_name” is the name of the action taken, which can be one of the following functions:
|
||||
# 1) CHATBOX[text], which you can use to talk with the user. "text" is in verbal English.
|
||||
# 1) CHAT_BOX[text], which you can use to talk with the user. "text" is in verbal English.
|
||||
# 2) WINESTOCK[query], which you can use to find info about wine in your inventory. "query" is a search term in verbal English. The best query must includes "budget", "type of wine", "characteristics of wine" and "food pairing".
|
||||
# "action_input" is the input to the action
|
||||
# "observation" is result of the preceding immediate action.
|
||||
|
||||
Reference in New Issue
Block a user