10 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
3 changed files with 55 additions and 54 deletions
+2 -2
View File
@@ -759,10 +759,10 @@ uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"
[[deps.SQLLLM]]
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LLMMCTS", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "FileIO", "GeneralUtils", "HTTP", "JSON", "LibPQ", "PrettyPrinting", "Random", "Revise", "StatsBase", "Tables", "URIs", "UUIDs"]
path = "."
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
version = "0.2.4"
version = "0.2.5"
[[deps.SQLStrings]]
git-tree-sha1 = "55de0530689832b1d3d43491ee6b67bd54d3323c"
+2 -2
View File
@@ -1,6 +1,6 @@
name = "SQLLLM"
uuid = "2ebc79c7-cc10-4a3a-9665-d2e1d61e63d3"
version = "0.2.5"
version = "0.2.6"
authors = ["narawat lamaiin <narawat@outlook.com>"]
[deps]
@@ -26,4 +26,4 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Dates = "1.11.0"
GeneralUtils = "0.4.0 - 0.9.0"
JSON = "1.6.1"
LLMMCTS = "0.1.5"
LLMMCTS = "0.1.5 - 0.9.0"
+51 -50
View File
@@ -118,9 +118,9 @@ function decisionMaker(state::T1, text2textInstructLLM::Function, llmFormatName:
<possible SQL for this question>
$similarSQL_
</possible SQL for this question>
<your earlier actions>
<assistant_action_history>
$(GeneralUtils.dict_to_string_html(state["action_history"]))
</your earlier actions>
</assistant_action_history>
<error_note>
$errornote
<error_note>
@@ -284,14 +284,16 @@ function evaluator(state::T1, text2textInstructLLM::Function, llmFormatName::Str
usermsg =
"""
<internal_context_for_assistant>
$(state["context"]["table_schema"])
<table_schema>
$(state["context"]["table_schema"])
</table_schema>
<customer question>
$(state["chathistory"][2]["content"][1]["text"])
</customer question>
<assistant_action_history>
$(GeneralUtils.dict_to_string_html(state["action_history"]))
</assistant_action_history>
</internal_context_for_assistant>
<customer question>
$(state["chathistory"][2]["content"][1]["text"])
</customer question>
<trajectories>
$(GeneralUtils.dict_to_string_html(state["action_history"]))
</trajectories>
"""
msg = Dict(
@@ -371,10 +373,10 @@ function evaluator(state::T1, text2textInstructLLM::Function, llmFormatName::Str
state["reward"] = responsedict["score"]
end
println("\n--- SQLLLM evaluator() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
pprintln(responsedict)
println("---\n")
# println("\n--- SQLLLM evaluator() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# pprintln(responsedict)
# println("---\n")
# error(7777)
return responsedict["score"]
end
error("Evaluator failed to generate an evaluation, Response: \n$response\n<|End of error|>")
@@ -596,16 +598,16 @@ function transition(state::T, args::NamedTuple
end
newNodeKey, newstate = makeNewState(state, thoughtDict, response)
progressvalue::Integer =
if response[:success]
8 # for faster agent response. if success just skip evaluation
else
evaluatorF(newstate, text2textInstructLLM, llmFormatName)
end
progressvalue::Integer = evaluatorF(newstate, text2textInstructLLM, llmFormatName)
# if response[:success]
# 8 # for faster agent response. if success just skip evaluation
# else
# evaluatorF(newstate, text2textInstructLLM, llmFormatName)
# end
println("\n--- SQLLLM transition() thoughtDict ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
pprintln(thoughtDict)
println("---")
# println("\n--- SQLLLM transition() thoughtDict ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# pprintln(thoughtDict)
# println("---")
# error("SQLLLM transition() end")
return (newNodeKey=newNodeKey, newstate=newstate, progressvalue=progressvalue)
end
@@ -727,42 +729,41 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
systemmsg =
"""
<available_actions>
- RUNSQL, which you can use to execute SQL against the database.
action_input for this function must be a single SQL query to be executed against the database.
For more effective text search, it's necessary to use case-insensitivity and the ILIKE operator.
Do not wrap the SQL as it will be executed against the database directly and SQL must be ended with ';'.
</available_actions>
<situation>
At each round of conversation, you will be given the following:
- user question
You are working under your mentor supervision and you are also eager to improve your helpfulness.
</situation>
<objective>
Consult the database search guidelines. Then find the data from a database to satisfy the user's question.
</objective>
<your responsibility includes>
Fulfill the objective.
</your responsibility includes>
<database search guidelines>
# database search guidelines
- Keep SQL queries focused only on the provided information.
- Do not create any table in the database
- A junction table can be used to link tables together. Another use case is for filtering data.
- If you can't find a single table that can be used to answer the user's query, try joining multiple tables to see if you can obtain the answer.
- Text information in the database usually stored in lower case. If your search returns empty, try using lower case to search.
- If there is no search result from the database, remove the restrictive criteria until a search result is available, and proceed from there.
</database search guidelines>
<you should then respond to the user with interleaving plan, action_name, action_input>
1) plan: Based on the current situation, state a complete action plan to complete the task. Be specific.
2) action_name: (Typically corresponds to the execution of the first step in your plan) Can be one of the available_actions name
3) action_input: The input to the action you are about to perform according to your plan.
# situation
At each round of conversation, you will be given the following:
- user question
You are working under your mentor supervision and you are also eager to improve your helpfulness.
# objective
Consult the database search guidelines. Then find the data from a database to satisfy the user's question.
# your responsibility includes
Fulfill the objective.
# you should then respond to the user with interleaving plan, action_name, action_input
1) **plan**, Based on the current situation, state a complete action plan to complete the task and rationale. Be specific.
2) **action_name**, (Typically corresponds to the execution of the first step in your plan) Can be one of the available_actions name
3) **action_input**, The input to the action you are about to perform according to your plan.
After the action is executed you gets "action_result". It is the output from the action you selected.
</you should then respond to the user with interleaving plan, action_name, action_input>
<you should only respond in JSON format as described below>
# you should only respond in JSON format as described below
"plan": "...",
"action_name": "...",
"action_input": "..."
</you should only respond in JSON format as described below>
# available_actions
**RUNSQL**, which you can use to execute SQL against the database.
The input must be a single SQL query to be executed against the database.
For more effective text search, it's necessary to use case-insensitivity and the ILIKE operator.
Do not wrap the SQL as it will be executed against the database directly and SQL must be ended with ';'.
"""
@@ -975,7 +976,7 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
end
println("\n--- SQLLLM query() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
println(resultState["result_raw"])
# pprintln(resultState)
println("---\n")
return (result_str=latest_action["action_result"], result_raw=resultState["result_raw"])
@@ -1001,7 +1002,7 @@ function makeNewState(currentstate::T1, thoughtDict::T2, response::NamedTuple,
if response[:success]
thoughtDict["action_result"] = response[:result_str]
else
error(response[:errormsg])
thoughtDict["action_result"] = response[:errormsg]
end
newstate = deepcopy(currentstate)