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

@@ -653,7 +653,7 @@ function evaluator(state::T1, text2textInstructLLM::Function;
1) Trajectory_evaluation: Analyze the trajectory of a solution to answer the user's original question. 1) Trajectory_evaluation: Analyze the trajectory of a solution to answer the user's original question.
- Evaluate the correctness of each section and the overall trajectory based on the given question. - Evaluate the correctness of each section and the overall trajectory based on the given question.
- Provide detailed reasoning and analysis, focusing on the latest thought, action, and observation. - Provide detailed reasoning and analysis, focusing on the latest thought, action, and observation.
- Incomplete trajectories are acceptable if the thoughts and actions up to that point are correct, even if the final answer isn't reached. - Incomplete trajectory are acceptable if the thoughts and actions up to that point are correct, even if the final answer isn't reached.
- Do not generate additional thoughts or actions. - Do not generate additional thoughts or actions.
2) Answer_evaluation: 2) Answer_evaluation:
- Focus only on the matter mentioned in the question and comprehensively analyze how the latest observation's details addresses the question - Focus only on the matter mentioned in the question and comprehensively analyze how the latest observation's details addresses the question
@@ -744,7 +744,7 @@ function evaluator(state::T1, text2textInstructLLM::Function;
addSQLVectorDB(state) addSQLVectorDB(state)
end end
end end
println("~~~ Evaluator() ", @__FILE__, " ", @__LINE__) println("\n~~~ Evaluator() ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict)) pprintln(Dict(responsedict))
return responsedict[:score] return responsedict[:score]

View File

@@ -518,7 +518,7 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
else else
end end
println("~~~ getdata_decisionMaker() ", @__FILE__, " ", @__LINE__) println("\n~~~ getdata_decisionMaker() ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict)) pprintln(Dict(responsedict))
return (thought=responsedict[:reasoning], code=code, success=true, errormsg=nothing) return (thought=responsedict[:reasoning], code=code, success=true, errormsg=nothing)
catch e catch e
@@ -562,7 +562,7 @@ julia> response = SQLLLM.SQLexecution(executeSQL, sql)
""" """
# function SQLexecution(executeSQL::Function, sql::T # 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} # )::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 # #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 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;" # # 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 # # add LIMIT to the SQL to prevent loading large data
# sql = strip(sql) # sql = strip(sql)
# println("~~~ SQL 1", @__FILE__, " ", @__LINE__) # println("\n~~~ SQL 1", @__FILE__, " ", @__LINE__)
# println(sql) # println(sql)
# println("~~~ 1-02 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 1-02 ", @__FILE__, " ", @__LINE__)
# if sql[end] != ';' # if sql[end] != ';'
# errorMsg = "Error, SQL execution failed because it does not ended with ';'" # errorMsg = "Error, SQL execution failed because it does not ended with ';'"
# return (result=nothing, success=false, errormsg=errorMsg, reward=0, isterminal=false) # return (result=nothing, success=false, errormsg=errorMsg, reward=0, isterminal=false)
# end # end
# println("~~~ 1-03 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 1-03 ", @__FILE__, " ", @__LINE__)
# if !occursin("LIMIT", sql) # if !occursin("LIMIT", sql)
# # sql = sql[1:end-1] * " LIMIT 100;" # # sql = sql[1:end-1] * " LIMIT 100;"
# sql = sql[1:end-1] * " ORDER BY RANDOM() LIMIT 2;" # sql = sql[1:end-1] * " ORDER BY RANDOM() LIMIT 2;"
# end # end
# println("~~~ SQL 2", @__FILE__, " ", @__LINE__) # println("\n~~~ SQL 2", @__FILE__, " ", @__LINE__)
# println(sql) # println(sql)
# println("~~~ 1-1 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 1-1 ", @__FILE__, " ", @__LINE__)
# result = executeSQL(sql) # result = executeSQL(sql)
# println("~~~ 1-2 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 1-2 ", @__FILE__, " ", @__LINE__)
# df = DataFrame(result) # df = DataFrame(result)
# println("~~~ raw df ", df) # println("\n~~~ raw df ", df)
# tablesize = size(df) # tablesize = size(df)
# println("~~~ df size ", tablesize) # println("\n~~~ df size ", tablesize)
# println("~~~ 6 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 6 ", @__FILE__, " ", @__LINE__)
# row = tablesize[1] # row = tablesize[1]
# println("~~~ 7 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 7 ", @__FILE__, " ", @__LINE__)
# if row == 0 # if 0 row # 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." # 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) # return (result=nothing, success=false, errormsg=errorMsg, reward=0, isterminal=false)
# end # end
# println("~~~ 8 ", @__FILE__, " ", @__LINE__) # println("\n~~~ 8 ", @__FILE__, " ", @__LINE__)
# df1 = # df1 =
# if row > 2 # if row > 2
# # ramdom row to pick # # ramdom row to pick
@@ -615,7 +615,7 @@ julia> response = SQLLLM.SQLexecution(executeSQL, sql)
# df # df
# end # end
# println("~~~ SQLexecution result ", @__FILE__, " ", @__LINE__) # println("\n~~~ SQLexecution result ", @__FILE__, " ", @__LINE__)
# println(df1) # println(df1)
# return (result=df1, success=true, errormsg=nothing, reward=1, isterminal=true) # return (result=df1, success=true, errormsg=nothing, reward=1, isterminal=true)
# end # end
@@ -644,7 +644,7 @@ function SQLexecution(executeSQL::Function, sql::T
else else
error("Error, SQL execution failed because it does not ended with ';'") error("Error, SQL execution failed because it does not ended with ';'")
end end
println("~~~ SQLexecution() SQL: ", @__FILE__, " ", @__LINE__) println("\n~~~ SQLexecution() SQL: ", @__FILE__, " ", @__LINE__)
println(sql) println(sql)
result = executeSQL(sql) result = executeSQL(sql)
@@ -666,7 +666,7 @@ function SQLexecution(executeSQL::Function, sql::T
df df
end end
println("~~~ SQLexecution() result: ", @__FILE__, " ", @__LINE__) println("\n~~~ SQLexecution() result: ", @__FILE__, " ", @__LINE__)
println(df1) println(df1)
return (result=df1, success=true, errormsg=nothing) return (result=df1, success=true, errormsg=nothing)
catch e 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." result *= "There are many more rows, but they are truncated because there are too many of them."
end end
println("~~~ extractContent_dataframe() ", @__FILE__, " ", @__LINE__) println("\n~~~ extractContent_dataframe() ", @__FILE__, " ", @__LINE__)
println(result) println(result)
return result return result