update
This commit is contained in:
+10
-53
@@ -1,10 +1,10 @@
|
||||
module llmfunction
|
||||
|
||||
export virtualWineUserChatbox, jsoncorrection, checkwine, # recommendbox,
|
||||
export virtualWineUserChatbox, jsoncorrection, checkwine!, # recommendbox,
|
||||
virtualWineUserRecommendbox, userChatbox, userRecommendbox, extractWineAttributes_1,
|
||||
extractWineAttributes_2, paraphrase
|
||||
|
||||
using HTTP, JSON, URIs, Random, PrettyPrinting, UUIDs, Dates, DataFrames
|
||||
using HTTP, JSON, URIs, Random, PrettyPrinting, UUIDs, Dates, DataFrames, DataStructures
|
||||
using GeneralUtils, SQLLLM
|
||||
using ..type, ..util
|
||||
|
||||
@@ -281,53 +281,14 @@ julia> input = "{\"food\": \"pizza\", \"occasion\": \"anniversary\"}"
|
||||
julia> result = checkinventory(agent, input)
|
||||
"{"wine 1": {\"Winery\": \"Pichon Baron\", \"wine name\": \"Pauillac (Grand Cru Classé)\", \"grape variety\": \"Cabernet Sauvignon\", \"year\": 2010, \"price\": \"125 USD\", \"stock ID\": \"ar-17\"}, }"
|
||||
```
|
||||
"""
|
||||
function checkwine(a::T1, input::T2; maxattempt::Int=3
|
||||
) where {T1<:agent, T2<:AbstractString}
|
||||
"""
|
||||
function checkwine!(a::T, thoughtdict::AbstractDict
|
||||
)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict, Any}} where {T<:agent}
|
||||
|
||||
println("\ncheckinventory order: $input ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
wineattributes_1 = extractWineAttributes_1(a, input)
|
||||
wineattributes_2 = extractWineAttributes_2(a, input)
|
||||
println("\ncheckinventory order: $(thoughtdict["action_input"]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
wineattributes_1 = extractWineAttributes_1(a, thoughtdict["action_input"])
|
||||
wineattributes_2 = extractWineAttributes_2(a, thoughtdict["action_input"])
|
||||
|
||||
# placeholder
|
||||
# textresult = nothing
|
||||
# rawresponse = nothing
|
||||
|
||||
# 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"
|
||||
|
||||
# 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")
|
||||
|
||||
# # 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}"
|
||||
@@ -340,15 +301,11 @@ function checkwine(a::T1, input::T2; maxattempt::Int=3
|
||||
insertSQLVectorDB=a.context.insertSQLVectorDB,
|
||||
similarSQLVectorDB=a.context.similarSQLVectorDB,
|
||||
llmFormatName="qwen3")
|
||||
# println("\n--- YiemAgent checkwine() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
# println(textresult)
|
||||
# println(result_raw)
|
||||
# println("---")
|
||||
thoughtdict["action_result"] = textresult
|
||||
|
||||
return (result_str=textresult, result_raw=result_raw, success=true, errormsg=nothing)
|
||||
return (thoughtdict=thoughtdict, result_raw=result_raw)
|
||||
end
|
||||
|
||||
|
||||
"""
|
||||
|
||||
# Arguments
|
||||
|
||||
Reference in New Issue
Block a user