21 Commits

Author SHA1 Message Date
ton 2efb016646 up version 2026-07-09 20:18:01 +07:00
ton 216a8bdabb Merge pull request 'v0.2.6-fix_too_many_decision' (#3) from v0.2.6-fix_too_many_decision into v0.2.6
Reviewed-on: #3
2026-07-09 13:16:22 +00:00
ton cbaa480e84 update evaluator 2026-07-09 19:44:37 +07:00
ton 6cb4073e29 update 2026-07-09 19:27:56 +07:00
ton 42b8f5bdb1 update 2026-07-09 06:53:14 +07:00
ton 35f1482228 md system prompt 2026-07-07 07:55:10 +07:00
ton b4cac4f383 update 2026-07-04 14:20:20 +07:00
ton 685ee7a48f update 2026-07-04 13:53:55 +07:00
ton b55ae31e5b update 2026-07-04 13:49:19 +07:00
ton e8e1764bb4 Merge pull request 'v0.3.0' (#2) from v0.3.0 into main
Reviewed-on: #2
2026-07-04 06:11:15 +00:00
ton e0b3ffa8e3 Merge pull request 'v0.3.0-use_openai_format' (#1) from v0.3.0-use_openai_format into v0.3.0
Reviewed-on: #1
2026-07-04 06:10:43 +00:00
ton ec9f44e5a1 update 2026-07-04 13:09:37 +07:00
ton 6b3f8620e1 update 2026-07-04 12:46:25 +07:00
ton 9cd37317d7 update 2026-07-02 18:31:00 +07:00
ton 1577d7ae25 update 2026-07-02 18:25:56 +07:00
ton c4e255ec2a update 2026-07-01 21:35:48 +07:00
ton 681a91a0ca update 2026-06-29 21:03:18 +07:00
ton c085a445e2 update 2026-06-29 20:55:52 +07:00
ton bc81033924 use string key for dict 2026-06-25 06:16:30 +07:00
ton f5875dcb61 update 2026-06-24 21:04:09 +07:00
ton 69208b2ffc update 2026-06-21 08:14:16 +07:00
10 changed files with 950 additions and 1043 deletions
+387 -211
View File
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -1,7 +1,7 @@
name = "SQLLLM" name = "SQLLLM"
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3" uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
version = "0.2.6"
authors = ["narawat lamaiin <narawat@outlook.com>"] authors = ["narawat lamaiin <narawat@outlook.com>"]
version = "0.2.4"
[deps] [deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
@@ -11,7 +11,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GeneralUtils = "c6c72f09-b708-4ac8-ac7c-2084d70108fe" GeneralUtils = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LLMMCTS = "d76c5a4d-449e-4835-8cc4-dd86ec44f241" LLMMCTS = "d76c5a4d-449e-4835-8cc4-dd86ec44f241"
LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1" LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1"
PrettyPrinting = "54e16d92-306c-5ea0-a30b-337be88ac337" PrettyPrinting = "54e16d92-306c-5ea0-a30b-337be88ac337"
@@ -24,3 +24,6 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[compat] [compat]
Dates = "1.11.0" Dates = "1.11.0"
GeneralUtils = "0.4.0 - 0.9.0"
JSON = "1.6.1"
LLMMCTS = "0.1.5 - 0.9.0"
+82
View File
@@ -0,0 +1,82 @@
BIN
View File
Binary file not shown.
+378 -717
View File
File diff suppressed because it is too large Load Diff
+72 -87
View File
@@ -3,7 +3,7 @@ module llmfunction
export listAllTable_json, listAllTable_str, tableinfo, getdata, finalAnswerBox, export listAllTable_json, listAllTable_str, tableinfo, getdata, finalAnswerBox,
getTableNameFromSQL, extractContent_dataframe, SQLexecution, compareState getTableNameFromSQL, extractContent_dataframe, SQLexecution, compareState
using HTTP, JSON3, URIs, Random, PrettyPrinting, UUIDs, LibPQ, Tables, DataFrames, CSV, using HTTP, JSON, URIs, Random, PrettyPrinting, UUIDs, LibPQ, Tables, DataFrames, CSV,
DataStructures, StatsBase, Dates DataStructures, StatsBase, Dates
using GeneralUtils, LLMMCTS using GeneralUtils, LLMMCTS
using ..util using ..util
@@ -189,7 +189,7 @@ function tableinfo(executeSQL::Function, tablenames::T
end end
end end
if !isempty(notExistingTable) if !isempty(notExistingTable)
result = "Error, the following tables does not exist in the database: $(JSON3.write(notExistingTable))" result = "Error, the following tables does not exist in the database: $(JSON.json(notExistingTable))"
return (result=result,) return (result=result,)
end end
@@ -287,17 +287,17 @@ function getdata_transition(state::T, args::NamedTuple
# decisionMaker::Function = args[:decisionMaker] # decisionMaker::Function = args[:decisionMaker]
# evaluator::Function = args[:evaluator] # evaluator::Function = args[:evaluator]
# reflector::Function = args[:reflector] # reflector::Function = args[:reflector]
context = args[:context] context = args["context"]
executeSQL::Function = args[:executeSQL] executeSQL::Function = args["executeSQL"]
text2textInstructLLM::Function = args[:text2textInstructLLM] text2textInstructLLM::Function = args["text2textInstructLLM"]
thought, sql = thought, sql =
if state[:code] !== nothing if state["code"] !== nothing
result = getdata_decisionMaker(state, context, text2textInstructLLM) result = getdata_decisionMaker(state, context, text2textInstructLLM)
result[:thought], result[:code] result["thought"], result["code"]
else else
nothing, state[:question] nothing, state["question"]
end end
# make new state # make new state
newNodeKey = GeneralUtils.uuid4snakecase() newNodeKey = GeneralUtils.uuid4snakecase()
@@ -314,15 +314,15 @@ function getdata_transition(state::T, args::NamedTuple
isterminal=false) isterminal=false)
end end
println("getdata_transition() 1 ", @__FILE__, " ", @__LINE__) println("getdata_transition() 1 ", @__FILE__, " ", @__LINE__)
newstate[:code] = sql newstate["code"] = sql
newstate[:response] = response newstate["response"] = response
newstate[:errorexplain] = thought newstate["errorexplain"] = thought
newstate[:errormsg] = errormsg newstate["errormsg"] = errormsg
newstate[:reward] = reward newstate["reward"] = reward
newstate[:isterminal] = isterminal newstate["isterminal"] = isterminal
if response !== nothing if response !== nothing
extracted = extractContent_dataframe(response, context, text2textInstructLLM) extracted = extractContent_dataframe(response, context, text2textInstructLLM)
newstate[:response] = extracted newstate["response"] = extracted
end end
println("getdata_transition() 2 ", @__FILE__, " ", @__LINE__) println("getdata_transition() 2 ", @__FILE__, " ", @__LINE__)
stateevaluation = "None" stateevaluation = "None"
@@ -389,10 +389,10 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
for attempt in 1:10 for attempt in 1:10
usermsg = """ usermsg = """
Context: Context:
$(context[:mentionedTableInfo]) $(context["mentionedTableInfo"])
User intention: $(context[:userintention]) User intention: $(context["userintention"])
Code executed from the last round: $(state[:code]) Code executed from the last round: $(state["code"])
Execution error: $(state[:errormsg]) Execution error: $(state["errormsg"])
$noise $noise
$note_flag $note_flag
""" """
@@ -414,13 +414,13 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
dictkey = ["plan", "code"] dictkey = ["plan", "code"]
responsedict = GeneralUtils.textToDict(response, header; responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true) dictKey=dictkey, symbolkey=false)
_code = responsedict[:code] _code = responsedict["code"]
code = strip(_code) code = strip(_code)
if length(code) < 2 if length(code) < 2
error("No code available.") error("No code available.")
elseif code == state[:code] elseif code == state["code"]
error("generated code is the same as earlier.") error("generated code is the same as earlier.")
else else
end end
@@ -440,7 +440,7 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
println("\n~~~ getdata_decisionMaker() ", @__FILE__, " ", @__LINE__) println("\n~~~ getdata_decisionMaker() ", @__FILE__, " ", @__LINE__)
pprintln(Dict(responsedict)) pprintln(Dict(responsedict))
return (thought=responsedict[:comprehension], code=code, success=true, errormsg=nothing) return (thought=responsedict["comprehension"], code=code, success=true, errormsg=nothing)
catch e catch e
io = IOBuffer() io = IOBuffer()
showerror(io, e) showerror(io, e)
@@ -481,20 +481,9 @@ julia> response = SQLLLM.SQLexecution(executeSQL, sql)
# Signature # Signature
""" """
function SQLexecution(executeSQL::Function, sql::T function SQLexecution(executeSQL::Function, sql::T
) where {T<:AbstractString} )::NamedTuple where {T<:AbstractString}
try try
#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;"
# sql = " SELECT COUNT(DISTINCT wf.wine_id) 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 ILIKE '%lamb%'"
#XXX use for package testing, remove when done
# ans = "1.schilfwein zweigelt 2.cabernet sauvignon reserve limited edition"
# ans = "There are 1500 wines that can be paired with lamb."
# ans = "1500"
# return (response=ans, errormsg=nothing, reward=1, isterminal=true)
# 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)
@@ -508,39 +497,36 @@ function SQLexecution(executeSQL::Function, sql::T
else else
sql = sql * ";" sql = sql * ";"
end end
println("\n~~~ SQLexecution() SQL: ", @__FILE__, " ", @__LINE__)
println(sql)
result = executeSQL(sql) result = executeSQL(sql)
df = DataFrame(result) df = DataFrame(result)
tablesize = size(df) tablesize = size(df)
row, column = tablesize row, column = tablesize
if row == 0 if row == 0
error("\nThe resulting table has 0 row. Please try again.") return (result_str="The resulting table has 0 row.", result_raw=df, success=true, errormsg=nothing)
elseif column > 30 elseif column > 30
error("\nSQL execution failed. An unexpected error occurred. Please try again.") return (result_str="There are more than 30 columns. Please be more specific.", result_raw=df, success=true, errormsg=nothing)
else
df1 =
if row > 2
# ramdom row to pick
df[sample(1:nrow(df), 2, replace=false), :] # random select 2 rows from df
else
df
end
result = GeneralUtils.dfToString(df1)
# println("\n~~~ SQLexecution() result: ", @__FILE__, " ", @__LINE__)
# println(sql)
# println(df1)
# println("\n")
return (result_str=result, result_raw=df1, success=true, errormsg=nothing)
end end
df1 =
if row > 2
# ramdom row to pick
df[sample(1:nrow(df), 2, replace=false), :] # random select 2 rows from df
else
df
end
println("\n~~~ SQLexecution() result: ", @__FILE__, " ", @__LINE__)
println(df1)
return (result=df1, success=true, errormsg=nothing)
catch e catch e
io = IOBuffer() io = IOBuffer()
showerror(io, e) showerror(io, e)
errorMsg = String(take!(io)) errorMsg = String(take!(io))
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace())) st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
println(errorMsg) println(errorMsg)
response = (result=nothing, success=false, errormsg=errorMsg) return (result_str=nothing, result_raw=nothing, success=false, errormsg=errorMsg)
return response
end end
end end
@@ -559,7 +545,7 @@ end
- `result::String` - `result::String`
# Signature # Signature
""" """ #WORKING
function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function, action::String, function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function, action::String,
llmFormatName::String llmFormatName::String
)::String )::String
@@ -633,7 +619,7 @@ function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function,
dictkey = ["about_resulting_table", "search_summary"] dictkey = ["about_resulting_table", "search_summary"]
for i in 1:5 for i in 1:5
response = text2textInstructLLM(prompt, modelsize="medium") response = text2textInstructLLM("ramdom_id", prompt)
response = GeneralUtils.deFormatLLMtext(response, llmFormatName) response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
think, response = GeneralUtils.extractthink(response) think, response = GeneralUtils.extractthink(response)
@@ -651,12 +637,11 @@ function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function,
end end
responsedict = GeneralUtils.textToDict(response, header; responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true) dictKey=dictkey, symbolkey=false)
# result = dfstr
result = result =
""" """
Summary: $(responsedict[:search_summary]) Summary: $(responsedict["search_summary"])
More details: $dfstr More details: $dfstr
""" """
@@ -778,8 +763,8 @@ function getTableNameFromSQL(sql::T, text2textInstructLLM::Function,
response = text2textInstructLLM(prompt, modelsize="medium") response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, llmFormatName) response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
responsedict = GeneralUtils.textToDict(response, header; responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true) dictKey=dictkey, symbolkey=false)
response = copy(JSON3.read(responsedict[:table_name])) response = copy(JSON.parse(responsedict["table_name"]))
return response return response
catch e catch e
@@ -821,7 +806,7 @@ julia>
# Notes # Notes
- The function makes up to 10 attempts to get a valid response from the LLM - The function makes up to 10 attempts to get a valid response from the LLM
- Each state in highValueStateList should contain a thoughtHistory with action_input and observation - Each state in highValueStateList should contain a action_history with action_input and observation
- The LLM evaluates attempts based on accuracy and relevance to the original question - The LLM evaluates attempts based on accuracy and relevance to the original question
""" """
function compareState(question::String, highValueStateList::Vector{T}, function compareState(question::String, highValueStateList::Vector{T},
@@ -862,21 +847,21 @@ function compareState(question::String, highValueStateList::Vector{T},
Let's begin! Let's begin!
""" """
potentialSolution = [] potentialSolution = []
keys = [:action_input, :observation] keys = ["action_input", "observation"]
# extract the last action_name, action_input, observation of each state in highValueStateList and store them in a dictionary then push into potentialSolution # extract the last action_name, action_input, observation of each state in highValueStateList and store them in a dictionary then push into potentialSolution
for state in highValueStateList for state in highValueStateList
thoughtHistory = state[:thoughtHistory] action_history = state["action_history"]
_, currentstate_latestIndice = _, currentstate_latestIndice =
GeneralUtils.findHighestIndexKey(thoughtHistory, keys[1]) GeneralUtils.findHighestIndexKey(action_history, keys[1])
latestKeys = makekey.(keys, currentstate_latestIndice) latestKeys = makekey.(keys, currentstate_latestIndice)
d = Dict() d = Dict()
# get the last action_name, action_input, observation of currentstate # get the last action_name, action_input, observation of currentstate
for (i,v) in enumerate(keys) for (i,v) in enumerate(keys)
d[v] = thoughtHistory[latestKeys[i]] d[v] = action_history[latestKeys[i]]
end end
push!(potentialSolution, d) push!(potentialSolution, d)
end end
""" """
# put potential solutions from potentialSolution into the following form # put potential solutions from potentialSolution into the following form
@@ -944,11 +929,11 @@ function compareState(question::String, highValueStateList::Vector{T},
continue continue
end end
responsedict = GeneralUtils.textToDict(response, header; dictKey=dictkey, symbolkey=true) responsedict = GeneralUtils.textToDict(response, header; dictKey=dictkey, symbolkey=false)
responsedict[:selected_response_number] = responsedict[:selected_response_number][1] # some time "6\nThe trajectories are incomplete" is generated but I only need the number. responsedict["selected_response_number"] = responsedict["selected_response_number"][1] # some time "6\nThe trajectories are incomplete" is generated but I only need the number.
try try
responsedict[:selected_response_number] = parse(Int, responsedict[:selected_response_number]) # convert string "5" into integer 5 responsedict["selected_response_number"] = parse(Int, responsedict["selected_response_number"]) # convert string "5" into integer 5
catch catch
errornote = "In your previous attempt, Selected_response_number was not a number. It must be a number." errornote = "In your previous attempt, Selected_response_number was not a number. It must be a number."
println("\nERROR SQLLLM compareState() Attempt $attempt. $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR SQLLLM compareState() Attempt $attempt. $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
@@ -958,7 +943,7 @@ function compareState(question::String, highValueStateList::Vector{T},
println("\n~~~ compareState() ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\n~~~ compareState() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
pprintln(Dict(responsedict)) pprintln(Dict(responsedict))
return responsedict[:selected_response_number] return responsedict["selected_response_number"]
end end
error("compareState() failed to generate an evaluation, Response: \n$response\n<|End of error|>", @__FILE__, ":", @__LINE__, " $(Dates.now())") error("compareState() failed to generate an evaluation, Response: \n$response\n<|End of error|>", @__FILE__, ":", @__LINE__, " $(Dates.now())")
end end
+1 -1
View File
@@ -2,7 +2,7 @@ module util
export makekey export makekey
makekey(key, indice) = Symbol("$(key)_$indice") makekey(key, indice) = "$(key)_$indice"
+9 -9
View File
@@ -1,9 +1,9 @@
using Revise using Revise
using LibPQ, Dates, JSON3, PrettyPrinting, UUIDs, DataFrames, DataStructures, Base64 using LibPQ, Dates, JSON, PrettyPrinting, UUIDs, DataFrames, DataStructures, Base64
using GeneralUtils, SQLLLM using GeneralUtils, SQLLLM
config = JSON3.read("/appfolder/app/dev/YiemAgent/test/config.json") config = JSON.parse("/appfolder/app/dev/YiemAgent/test/config.json")
function executeSQL(sql::T) where {T<:AbstractString} function executeSQL(sql::T) where {T<:AbstractString}
host = config[:externalservice][:wineDB][:host] host = config[:externalservice][:wineDB][:host]
@@ -137,7 +137,7 @@ end
function insertSQLVectorDB(query::T1, SQL::T2; maxdistance::Integer=3) where {T1<:AbstractString, T2<:AbstractString} function insertSQLVectorDB(query::T1, SQL::T2; maxdistance::Integer=3) where {T1<:AbstractString, T2<:AbstractString}
tablename = "sqlllm_decision_repository" tablename = "sqlllm_decision_repository"
# get embedding of the query # get embedding of the query
# query = state[:thoughtHistory][:question] # query = state[:action_history][:question]
df = findSimilarTextFromVectorDB(query, tablename, df = findSimilarTextFromVectorDB(query, tablename,
"function_input_embedding", executeSQLVectorDB) "function_input_embedding", executeSQLVectorDB)
row, col = size(df) row, col = size(df)
@@ -173,7 +173,7 @@ function similarSommelierDecision(recentevents::T1; maxdistance::Integer=3
println("\n~~~ found similar decision. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__) println("\n~~~ found similar decision. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__)
output_b64 = df[1, :function_output_base64] # pick the closest match output_b64 = df[1, :function_output_base64] # pick the closest match
_output_str = String(base64decode(output_b64)) _output_str = String(base64decode(output_b64))
output = copy(JSON3.read(_output_str)) output = copy(JSON.parse(_output_str))
return output return output
else else
println("\n~~~ similar decision not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__) println("\n~~~ similar decision not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__)
@@ -193,7 +193,7 @@ function insertSommelierDecision(recentevents::T1, decision::T2; maxdistance::In
if row == 0 || distance > maxdistance # no close enough SQL stored in the database if row == 0 || distance > maxdistance # no close enough SQL stored in the database
recentevents_embedding = getEmbedding(recentevents)[1] recentevents_embedding = getEmbedding(recentevents)[1]
recentevents = replace(recentevents, "'" => "") recentevents = replace(recentevents, "'" => "")
decision_json = JSON3.write(decision) decision_json = JSON.json(decision)
decision_base64 = base64encode(decision_json) decision_base64 = base64encode(decision_json)
decision = replace(decision_json, "'" => "") decision = replace(decision_json, "'" => "")
@@ -212,14 +212,14 @@ sessionId = GeneralUtils.uuid4snakecase()
d = Dict(:id => sessionId) d = Dict(:id => sessionId)
filepath = "/appfolder/app/sessionid.json" filepath = "/appfolder/app/sessionid.json"
open(filepath, "w") do io open(filepath, "w") do io
JSON3.pretty(io, d) JSON.pretty(io, d)
end end
# query = "How many German wines do you have?" # query = "How many German wines do you have?"
# highValueStateList = copy(JSON3.read("/appfolder/app/highValueState_1.json")) # highValueStateList = copy(JSON.parse("/appfolder/app/highValueState_1.json"))
# selectedState = SQLLLM.compareState(query, highValueStateList, text2textInstructLLM) # selectedState = SQLLLM.compareState(query, highValueStateList, text2textInstructLLM)
@@ -352,8 +352,8 @@ SELECT * FROM wine WHERE wine_type = 'red' AND country = 'France' AND sweetness
# :evaluation => # :evaluation =>
# "The user's question is to search the database for wines that have a type of \"white\", are from \"France\", and have a sweetness level of 1. The thought is correct in identifying the conditions needed to filter the wine table. The action taken is to execute a SQL query to retrieve the desired data, which is also correct. The observation provides a search summary and two search results that match the user's question. Each result includes details about the wine such as ID, name, brand, manufacturer, region, country, type, grape variety, serving temperature, intensity, sweetness, tannin, and acidity.", # "The user's question is to search the database for wines that have a type of \"white\", are from \"France\", and have a sweetness level of 1. The thought is correct in identifying the conditions needed to filter the wine table. The action taken is to execute a SQL query to retrieve the desired data, which is also correct. The observation provides a search summary and two search results that match the user's question. Each result includes details about the wine such as ID, name, brand, manufacturer, region, country, type, grape variety, serving temperature, intensity, sweetness, tannin, and acidity.",
# :accepted_as_answer => "Yes", # :accepted_as_answer => "Yes",
# :thoughtHistory => # :action_history =>
# OrderedDict{Symbol, Any}(:question => "Search the database for wine_type: white, country: France, sweetness: 1", :thought_1 => "The user wants to search the database for wines that have a type of \"white\", are from \"France\", and have a sweetness level of 1. To achieve this, we need to filter the wine table based on these conditions.", :action_name_1 => "GETDATA", :action_input_1 => "SELECT * FROM wine WHERE wine.wine_type = 'white' AND wine.country = 'France' AND wine.sweetness = 1;", :observation_1 => "\"Search summary: The resulting table represents wines.\\nSearch result: 1) wine_id: 5b6b6df9-d87c-4f33-8995-7249c2ecc917, wine_name: corton-charlemagne grand cru, brand: domaine des croix, manufacturer: domaine des croix, region: bourgogne, country: France, wine_type: white, grape_variety: cote de beaune blanc, serving_temperature: 11 to 13 Celsius, intensity: 4, sweetness: 1, tannin: missing, acidity: 3, fizziness: missing\\n2) wine_id: 1ad27d16-ef64-4907-acf1-40631630c143, wine_name: puligny-montrachet 1er cru 'les demoiselles', brand: amiot guy, manufacturer: amiot guy, region: bourgogne, country: France, wine_type: white, grape_variety: cote de beaune blanc, serving_temperature: 11 to 13 Celsius, intensity: 4, sweetness: 1, tannin: missing, acidity: 3, fizziness: missing\\n\\n\""), # OrderedDict{String, Any}("question" => "Search the database for wine_type: white, country: France, sweetness: 1", "thought_1" => "The user wants to search the database for wines that have a type of \"white\", are from \"France\", and have a sweetness level of 1. To achieve this, we need to filter the wine table based on these conditions.", "action_name_1" => "GETDATA", "action_input_1" => "SELECT * FROM wine WHERE wine.wine_type = 'white' AND wine.country = 'France' AND wine.sweetness = 1;", "observation_1" => "\"Search summary: The resulting table represents wines.\\nSearch result: 1) wine_id: 5b6b6df9-d87c-4f33-8995-7249c2ecc917, wine_name: corton-charlemagne grand cru, brand: domaine des croix, manufacturer: domaine des croix, region: bourgogne, country: France, wine_type: white, grape_variety: cote de beaune blanc, serving_temperature: 11 to 13 Celsius, intensity: 4, sweetness: 1, tannin: missing, acidity: 3, fizziness: missing\\n2) wine_id: 1ad27d16-ef64-4907-acf1-40631630c143, wine_name: puligny-montrachet 1er cru 'les demoiselles', brand: amiot guy, manufacturer: amiot guy, region: bourgogne, country: France, wine_type: white, grape_variety: cote de beaune blanc, serving_temperature: 11 to 13 Celsius, intensity: 4, sweetness: 1, tannin: missing, acidity: 3, fizziness: missing\\n\\n\""),
# :evaluationscore => 9, # :evaluationscore => 9,
# :select => nothing, # :select => nothing,
# :suggestion => "None") # :suggestion => "None")
+2 -2
View File
@@ -1,5 +1,5 @@
using Revise using Revise
using LibPQ, JSON3, PrettyPrinting, UUIDs, DataFrames, DataStructures, Dates, MQTTClient, Random using LibPQ, JSON, PrettyPrinting, UUIDs, DataFrames, DataStructures, Dates, MQTTClient, Random
using SQLLLM, GeneralUtils using SQLLLM, GeneralUtils
@@ -39,7 +39,7 @@ df = DataFrame(result)
config = copy(JSON3.read("config.json")) config = copy(JSON.parse("config.json"))
msgMeta = GeneralUtils.generate_msgMeta( msgMeta = GeneralUtils.generate_msgMeta(
config[:externalservice][:text2textinstruct][:mqtttopic]; config[:externalservice][:text2textinstruct][:mqtttopic];
+2 -2
View File
@@ -1,8 +1,8 @@
# using Revise # using Revise
# using SQLLLM, LLMMCTS, DataStructures, JSON3 # using SQLLLM, LLMMCTS, DataStructures, JSON
# query = "How many German wines do you have?" # query = "How many German wines do you have?"
# highValueStateList = copy(JSON3.read("/appfolder/app/highValueState_1.json")) # highValueStateList = copy(JSON.parse("/appfolder/app/highValueState_1.json"))
# selectedState = SQLLLM.compareState(query, highValueStateList) # selectedState = SQLLLM.compareState(query, highValueStateList)