update
This commit is contained in:
+5
-5
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
julia_version = "1.12.6"
|
julia_version = "1.12.6"
|
||||||
manifest_format = "2.0"
|
manifest_format = "2.0"
|
||||||
project_hash = "dc7878808bbc4637a12e709dd495979a784824a5"
|
project_hash = "fec141f7ff95c7150e820def295f9929445168b6"
|
||||||
|
|
||||||
[[deps.Accessors]]
|
[[deps.Accessors]]
|
||||||
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"]
|
||||||
@@ -300,11 +300,11 @@ version = "1.1.0"
|
|||||||
|
|
||||||
[[deps.GeneralUtils]]
|
[[deps.GeneralUtils]]
|
||||||
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "Graphs", "HTTP", "JSON", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SHA", "StringDistances", "UUIDs"]
|
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "Graphs", "HTTP", "JSON", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SHA", "StringDistances", "UUIDs"]
|
||||||
git-tree-sha1 = "a75a088ee8e5faf10f554ca00748e0e6ca58d1ca"
|
git-tree-sha1 = "596da266c851d00fbabcf33660419aeffb820fcb"
|
||||||
repo-rev = "main"
|
repo-rev = "main"
|
||||||
repo-url = "https://git.yiem.cc/ton/GeneralUtils"
|
repo-url = "https://git.yiem.cc/ton/GeneralUtils"
|
||||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
||||||
version = "0.5.1"
|
version = "0.5.7"
|
||||||
|
|
||||||
[[deps.Graphs]]
|
[[deps.Graphs]]
|
||||||
deps = ["ArnoldiMethod", "DataStructures", "Inflate", "LinearAlgebra", "Random", "SimpleTraits", "SparseArrays", "Statistics"]
|
deps = ["ArnoldiMethod", "DataStructures", "Inflate", "LinearAlgebra", "Random", "SimpleTraits", "SparseArrays", "Statistics"]
|
||||||
@@ -1089,10 +1089,10 @@ uuid = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
|
|||||||
version = "0.4.16"
|
version = "0.4.16"
|
||||||
|
|
||||||
[[deps.YiemAgent]]
|
[[deps.YiemAgent]]
|
||||||
deps = ["Base64", "CSV", "DataFrames", "DataStructures", "Dates", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SQLLLM", "Serialization", "URIs", "UUIDs"]
|
deps = ["Base64", "CSV", "DataFrames", "DataStructures", "Dates", "HTTP", "JSON", "LLMMCTS", "LibPQ", "NATS", "PrettyPrinting", "Random", "Revise", "SQLLLM", "Serde", "Serialization", "URIs", "UUIDs"]
|
||||||
path = "."
|
path = "."
|
||||||
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
|
||||||
version = "0.7.2"
|
version = "0.7.4"
|
||||||
|
|
||||||
[[deps.Zlib_jll]]
|
[[deps.Zlib_jll]]
|
||||||
deps = ["Libdl"]
|
deps = ["Libdl"]
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
|||||||
Base64 = "1.11.0"
|
Base64 = "1.11.0"
|
||||||
CSV = "0.10.15"
|
CSV = "0.10.15"
|
||||||
DataFrames = "1.7.0"
|
DataFrames = "1.7.0"
|
||||||
GeneralUtils = "0.5.1"
|
GeneralUtils = "0.5.7"
|
||||||
HTTP = "2.4.0"
|
HTTP = "2.4.0"
|
||||||
JSON = "1.6.1"
|
JSON = "1.6.1"
|
||||||
LLMMCTS = "0.1.5"
|
LLMMCTS = "0.1.5"
|
||||||
|
|||||||
+16
-15
@@ -302,11 +302,17 @@ function search_wine_database!(a::T, thoughtdict::AbstractDict; useSQLLLM::Bool=
|
|||||||
else
|
else
|
||||||
|
|
||||||
# direct query with possible sql instead of SQLLLM.
|
# direct query with possible sql instead of SQLLLM.
|
||||||
sql = predefined_wine_search_sql(a, thoughtdict["action_input"])
|
hard_conditions, vector_search_words = wine_search_term_classification(a, thoughtdict["action_input"])
|
||||||
|
|
||||||
|
# do hard filter
|
||||||
# sql = generatesql(a, inventoryquery)
|
# sql = generatesql(a, inventoryquery)
|
||||||
println("\nSQL: $sql ", @__FILE__, ":", @__LINE__, " $(Dates.now()) \n")
|
sql = predefined_wine_search_sql(hard_conditions)
|
||||||
|
@info "\nsql: $sql, \nvector_search_words: $vector_search_words"
|
||||||
textresult, sql_result_df, success, _ = SQLexecution(a.context.executeSQL, sql)
|
textresult, sql_result_df, success, _ = SQLexecution(a.context.executeSQL, sql)
|
||||||
|
|
||||||
|
#WORKING do vector search
|
||||||
|
GeneralUtils.find_text_vector_similarity(vector_search_words, "wine")
|
||||||
|
|
||||||
items = nothing
|
items = nothing
|
||||||
if sql_result_df !== nothing
|
if sql_result_df !== nothing
|
||||||
result_vec = GeneralUtils.dfToVectorDict(sql_result_df)
|
result_vec = GeneralUtils.dfToVectorDict(sql_result_df)
|
||||||
@@ -619,9 +625,9 @@ julia> thoughtdict =
|
|||||||
```
|
```
|
||||||
julia> predefined_wine_search_sql(agent, thoughtdict["action_input"])
|
julia> predefined_wine_search_sql(agent, thoughtdict["action_input"])
|
||||||
"""
|
"""
|
||||||
function predefined_wine_search_sql(a::T, searchterm::String,
|
function wine_search_term_classification(a::T, searchterm::String,
|
||||||
; maxattempt=10
|
; maxattempt=10
|
||||||
)::String where {T<:agent}
|
) where {T<:agent}
|
||||||
|
|
||||||
systemmsg =
|
systemmsg =
|
||||||
"""
|
"""
|
||||||
@@ -641,7 +647,7 @@ function predefined_wine_search_sql(a::T, searchterm::String,
|
|||||||
The "extracted_info" key must contain an array of objects. Each object must contain:
|
The "extracted_info" key must contain an array of objects. Each object must contain:
|
||||||
1) "table_name": The name of the table.
|
1) "table_name": The name of the table.
|
||||||
2) "column_name": The specific column being filtered.
|
2) "column_name": The specific column being filtered.
|
||||||
3) "operator": The comparison operator (e.g., "=", ">", "LIKE").
|
3) "operator": The comparison operator (e.g., "=", ">").
|
||||||
4) "value": The value to compare against.
|
4) "value": The value to compare against.
|
||||||
|
|
||||||
If the user does not specify any filters, return an empty array for "extracted_info": {"extracted_info": []}.
|
If the user does not specify any filters, return an empty array for "extracted_info": {"extracted_info": []}.
|
||||||
@@ -668,7 +674,7 @@ function predefined_wine_search_sql(a::T, searchterm::String,
|
|||||||
{
|
{
|
||||||
"table_name": "car_info",
|
"table_name": "car_info",
|
||||||
"column_name": "drive_feeling",
|
"column_name": "drive_feeling",
|
||||||
"operator": "ILIKE",
|
"operator": "=",
|
||||||
"value": "fast and furious"
|
"value": "fast and furious"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -781,7 +787,7 @@ function predefined_wine_search_sql(a::T, searchterm::String,
|
|||||||
println("\n ", responsedict)
|
println("\n ", responsedict)
|
||||||
@info "before BM25 " @__LINE__
|
@info "before BM25 " @__LINE__
|
||||||
|
|
||||||
#WORKING to ensure user input is correct
|
# to ensure user input is correct
|
||||||
for entry in responsedict["extracted_info"]
|
for entry in responsedict["extracted_info"]
|
||||||
table_name = entry["table_name"]::String
|
table_name = entry["table_name"]::String
|
||||||
column_name = entry["column_name"]::String
|
column_name = entry["column_name"]::String
|
||||||
@@ -802,11 +808,12 @@ function predefined_wine_search_sql(a::T, searchterm::String,
|
|||||||
|
|
||||||
# Build new list of hard condition entries
|
# Build new list of hard condition entries
|
||||||
hard_conditions = JSON.Object{String, Any}[]
|
hard_conditions = JSON.Object{String, Any}[]
|
||||||
|
vector_search = JSON.Object{String, Any}[]
|
||||||
for entry in responsedict["extracted_info"]
|
for entry in responsedict["extracted_info"]
|
||||||
if entry["operator"] ∈ hard_operators
|
if entry["operator"] ∈ hard_operators
|
||||||
push!(hard_conditions, entry)
|
push!(hard_conditions, entry)
|
||||||
else
|
else
|
||||||
vector_search_words = vector_search_words * entry["value"] * ", "
|
push!(vector_search, entry)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
responsedict = hard_conditions
|
responsedict = hard_conditions
|
||||||
@@ -815,13 +822,7 @@ function predefined_wine_search_sql(a::T, searchterm::String,
|
|||||||
@show responsedict
|
@show responsedict
|
||||||
@info "predefined_wine_search_sql() " @__LINE__
|
@info "predefined_wine_search_sql() " @__LINE__
|
||||||
|
|
||||||
#WORKING do vector search
|
return (hard_conditions=hard_conditions, vector_search=vector_search)
|
||||||
println("")
|
|
||||||
@show vector_search_words
|
|
||||||
# error(9999)
|
|
||||||
sql = predefined_wine_search_sql(responsedict)
|
|
||||||
|
|
||||||
return sql
|
|
||||||
end
|
end
|
||||||
error("SQLLLM DecisionMaker() failed to generate a thought \n", response)
|
error("SQLLLM DecisionMaker() failed to generate a thought \n", response)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user