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 =
"""
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.
For your information:
- Observation: Result of the immediately preceding action
At each round of conversation, you will be given the following information:
User Query: ...
Closest SQL: The closest known SQL for this query
Your work progress: your progress so far
Evaluation: Evaluation of the immediately preceding action and observation
Suggestion: Suggestion for the immediately preceding action and observation
table_schema: schema of tables in the database
most_relevant_SQL: The closest known SQL for this question
query_result_of_most_relevant_SQL: the query result when executing the most_relevant_SQL against a database.
progress: your progress so far
evaluation: Evaluation of the immediately preceding action and observation
suggestion: Suggestion for the immediately preceding action and observation
You must follow the following guidelines:
- Keep SQL queries focused only on the provided information.
@@ -207,11 +208,24 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
context =
"""
<context>
<table_schema>
$(additionalinfo[:tablelist])
Closest SQL: $similarSQL_
Your work progress: $workprogress
Evaluation: $(state[:evaluation])
Suggestion: $(state[:suggestion])
</table_schema>
<most_relevant_SQL>
$similarSQL_
</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>
"""
@@ -230,7 +244,7 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
response = GeneralUtils.deFormatLLMtext(response, llmFormatName)
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
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:
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:
- When the search returns no result, validate whether the SQL query makes sense before accepting it as a valid answer.
@@ -696,7 +711,9 @@ function evaluator(state::T1, additionalinfo, text2textInstructLLM::Function, ll
context =
"""
<context>
<table_schema>
$(additionalinfo[:tablelist])
</table_schema>
P.S. $errornote
</context>
"""
@@ -1171,7 +1188,6 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
context = Dict(
:tablelist =>
"""
Here are SQL that used to create tables in the database:
create table customer (
customer_id uuid primary key default gen_random_uuid (),
customer_firstname varchar(128),