This commit is contained in:
narawat lamaiin
2025-05-17 21:36:40 +07:00
parent 8c5b1b6938
commit 0a0e36d86a

View File

@@ -135,18 +135,19 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
systemmsg = systemmsg =
""" """
You are a helpful assistant that find the data from a database to satisfy the user's query. You are a helpful assistant that find the data from a database to satisfy the user's question.
You are also eager to improve your helpfulness. You are also eager to improve your helpfulness.
For your information: For your information:
- Observation: Result of the immediately preceding action - Observation: Result of the immediately preceding action
At each round of conversation, you will be given the following information: At each round of conversation, you will be given the following information:
User Query: ... table_schema: schema of tables in the database
Closest SQL: The closest known SQL for this query most_relevant_SQL: The closest known SQL for this question
Your work progress: your progress so far query_result_of_most_relevant_SQL: the query result when executing the most_relevant_SQL against a database.
Evaluation: Evaluation of the immediately preceding action and observation progress: your progress so far
Suggestion: Suggestion for the immediately preceding action and observation evaluation: Evaluation of the immediately preceding action and observation
suggestion: Suggestion for the immediately preceding action and observation
You must follow the following guidelines: You must follow the following guidelines:
- Keep SQL queries focused only on the provided information. - Keep SQL queries focused only on the provided information.
@@ -207,12 +208,25 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
context = context =
""" """
<context> <context>
$(additionalinfo[:tablelist]) <table_schema>
Closest SQL: $similarSQL_ $(additionalinfo[:tablelist])
Your work progress: $workprogress </table_schema>
Evaluation: $(state[:evaluation]) <most_relevant_SQL>
Suggestion: $(state[:suggestion]) $similarSQL_
P.S. $errornote </most_relevant_SQL>
<query_result_of_most_relevant_SQL>
winery: Chateau Montelena, wine_name: The Montelena Estate Cabernet Sauvignon, wine_id: 97264f71-007c-4cce-a3fe-2cc88fba4d05, vintage: 2017, region: Napa Valley, country: United States, wine_type: red, grape: Cabernet Sauvignon, serving_temperature: 15 to 18 Celsius, sweetness: 1, intensity: 5, tannin: 4, acidity: 4, tasting_notes: oak, vanilla, tobacco, blackberry, plum, black cherry, leather, earthy, smoke, price: 19.95, currency: USD
</query_result_of_most_relevant_SQL>
<progress>
$workprogress
</progress>
<evaluation>
$(state[:evaluation])
</evaluation>
<suggestion>
$(state[:suggestion])
</suggestion>
P.S. $errornote
</context> </context>
""" """
@@ -230,7 +244,7 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
response = GeneralUtils.deFormatLLMtext(response, llmFormatName) response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
think, response = GeneralUtils.extractthink(response) think, response = GeneralUtils.extractthink(response)
#[WORKING] check for tasting_notes occurs AFTER where in the sql
# LLM tends to generate observation given that it is in the input # LLM tends to generate observation given that it is in the input
response = response =
@@ -640,6 +654,7 @@ function evaluator(state::T1, additionalinfo, text2textInstructLLM::Function, ll
At each round of conversation, you will be given the following information: At each round of conversation, you will be given the following information:
Trajectory: A history of how you worked on the question chronologically. Trajectory: A history of how you worked on the question chronologically.
table_schema: schema of tables in the database
You must follow the following guidelines: You must follow the following guidelines:
- When the search returns no result, validate whether the SQL query makes sense before accepting it as a valid answer. - When the search returns no result, validate whether the SQL query makes sense before accepting it as a valid answer.
@@ -696,8 +711,10 @@ function evaluator(state::T1, additionalinfo, text2textInstructLLM::Function, ll
context = context =
""" """
<context> <context>
$(additionalinfo[:tablelist]) <table_schema>
P.S. $errornote $(additionalinfo[:tablelist])
</table_schema>
P.S. $errornote
</context> </context>
""" """
@@ -1171,7 +1188,6 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
context = Dict( context = Dict(
:tablelist => :tablelist =>
""" """
Here are SQL that used to create tables in the database:
create table customer ( create table customer (
customer_id uuid primary key default gen_random_uuid (), customer_id uuid primary key default gen_random_uuid (),
customer_firstname varchar(128), customer_firstname varchar(128),