This commit is contained in:
narawat lamaiin
2024-10-14 12:50:00 +07:00
parent 8ceea33218
commit 04eb85b67e
2 changed files with 19 additions and 19 deletions

View File

@@ -518,7 +518,7 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
else
end
println("~~~ getdata_decisionMaker() ", @__FILE__, " ", @__LINE__)
println("\n~~~ getdata_decisionMaker() ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict))
return (thought=responsedict[:reasoning], code=code, success=true, errormsg=nothing)
catch e
@@ -562,7 +562,7 @@ julia> response = SQLLLM.SQLexecution(executeSQL, sql)
"""
# function SQLexecution(executeSQL::Function, sql::T
# )::NamedTuple{(:result, :success, :errormsg, :reward, :isterminal), Tuple{Union{DataFrame, Nothing}, Bool, Union{String, Nothing}, Integer, Bool}} where {T<:AbstractString}
# println("~~~ 1-01 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 1-01 ", @__FILE__, " ", @__LINE__)
# #XXX dummy SQL. use for testing
# # sql = "SELECT w.wine_name FROM wine w JOIN wine_food wf ON w.wine_id = wf.wine_id JOIN food f ON wf.food_id = f.food_id WHERE f.\"food_name\" = 'lamb';"
# # sql = " SELECT w.wine_name FROM wine w JOIN food f ON f.food_name = 'lamb' JOIN wine_food wf ON w.wine_id = wf.wine_id AND f.food_id = wf.food_id GROUP BY w.wine_name ORDER BY COUNT(DISTINCT w.wine_id) DESC;"
@@ -576,37 +576,37 @@ julia> response = SQLLLM.SQLexecution(executeSQL, sql)
# # add LIMIT to the SQL to prevent loading large data
# sql = strip(sql)
# println("~~~ SQL 1", @__FILE__, " ", @__LINE__)
# println("\n~~~ SQL 1", @__FILE__, " ", @__LINE__)
# println(sql)
# println("~~~ 1-02 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 1-02 ", @__FILE__, " ", @__LINE__)
# if sql[end] != ';'
# errorMsg = "Error, SQL execution failed because it does not ended with ';'"
# return (result=nothing, success=false, errormsg=errorMsg, reward=0, isterminal=false)
# end
# println("~~~ 1-03 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 1-03 ", @__FILE__, " ", @__LINE__)
# if !occursin("LIMIT", sql)
# # sql = sql[1:end-1] * " LIMIT 100;"
# sql = sql[1:end-1] * " ORDER BY RANDOM() LIMIT 2;"
# end
# println("~~~ SQL 2", @__FILE__, " ", @__LINE__)
# println("\n~~~ SQL 2", @__FILE__, " ", @__LINE__)
# println(sql)
# println("~~~ 1-1 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 1-1 ", @__FILE__, " ", @__LINE__)
# result = executeSQL(sql)
# println("~~~ 1-2 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 1-2 ", @__FILE__, " ", @__LINE__)
# df = DataFrame(result)
# println("~~~ raw df ", df)
# println("\n~~~ raw df ", df)
# tablesize = size(df)
# println("~~~ df size ", tablesize)
# println("~~~ 6 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ df size ", tablesize)
# println("\n~~~ 6 ", @__FILE__, " ", @__LINE__)
# row = tablesize[1]
# println("~~~ 7 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 7 ", @__FILE__, " ", @__LINE__)
# if row == 0 # if 0 row
# errorMsg = "The resulting table has 0 row. Possible causes: 1) SQL is incorrect 2) There is no data that match your search criteria."
# return (result=nothing, success=false, errormsg=errorMsg, reward=0, isterminal=false)
# end
# println("~~~ 8 ", @__FILE__, " ", @__LINE__)
# println("\n~~~ 8 ", @__FILE__, " ", @__LINE__)
# df1 =
# if row > 2
# # ramdom row to pick
@@ -615,7 +615,7 @@ julia> response = SQLLLM.SQLexecution(executeSQL, sql)
# df
# end
# println("~~~ SQLexecution result ", @__FILE__, " ", @__LINE__)
# println("\n~~~ SQLexecution result ", @__FILE__, " ", @__LINE__)
# println(df1)
# return (result=df1, success=true, errormsg=nothing, reward=1, isterminal=true)
# end
@@ -644,7 +644,7 @@ function SQLexecution(executeSQL::Function, sql::T
else
error("Error, SQL execution failed because it does not ended with ';'")
end
println("~~~ SQLexecution() SQL: ", @__FILE__, " ", @__LINE__)
println("\n~~~ SQLexecution() SQL: ", @__FILE__, " ", @__LINE__)
println(sql)
result = executeSQL(sql)
@@ -666,7 +666,7 @@ function SQLexecution(executeSQL::Function, sql::T
df
end
println("~~~ SQLexecution() result: ", @__FILE__, " ", @__LINE__)
println("\n~~~ SQLexecution() result: ", @__FILE__, " ", @__LINE__)
println(df1)
return (result=df1, success=true, errormsg=nothing)
catch e
@@ -780,7 +780,7 @@ function extractContent_dataframe(df::DataFrame, context::Dict, text2textInstruc
result *= "There are many more rows, but they are truncated because there are too many of them."
end
println("~~~ extractContent_dataframe() ", @__FILE__, " ", @__LINE__)
println("\n~~~ extractContent_dataframe() ", @__FILE__, " ", @__LINE__)
println(result)
return result