This commit is contained in:
narawat lamaiin
2025-06-03 10:08:17 +07:00
parent b3537a83e0
commit ff4db039ab
2 changed files with 67 additions and 67 deletions

View File

@@ -231,11 +231,11 @@ 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)
if occursin("NULL", response) # if occursin("NULL", response)
errornote = "\nYour previous attempt was NULL. This is not allowed" # errornote = "\nYour previous attempt contain NULL. It is not allowed in your response"
println("\nERROR SQLLLM decisionMaker(). Attempt $attempt/$maxattempt. $errornote ", @__FILE__, ":", @__LINE__, " $(Dates.now())") # println("\nERROR SQLLLM decisionMaker(). Attempt $attempt/$maxattempt. $errornote --(not qualify response)--> \n$response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue # continue
end # end
responsedict = nothing responsedict = nothing
try try
@@ -252,13 +252,13 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys) if length(is_requiredKeys_in_responsedictKey) > length(requiredKeys)
errornote = "Your previous attempt has more key points than answer's required key points." errornote = "Your previous attempt has more key points than answer's required key points."
println("\nERROR YiemAgent generatechat() $errornote --> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
elseif !all(is_requiredKeys_in_responsedictKey) elseif !all(is_requiredKeys_in_responsedictKey)
zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey) zeroind = findall(x -> x == 0, is_requiredKeys_in_responsedictKey)
missingkeys = [requiredKeys[i] for i in zeroind] missingkeys = [requiredKeys[i] for i in zeroind]
errornote = "$missingkeys are missing from your previous response" errornote = "$missingkeys are missing from your previous response"
println("\nERROR YiemAgent generatechat() $errornote --> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)--> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
end end
@@ -279,14 +279,14 @@ function decisionMaker(state::T1, additionalinfo, text2textInstructLLM::Function
toollist = ["TABLEINFO", "RUNSQL"] toollist = ["TABLEINFO", "RUNSQL"]
if responsedict[:action_name] toollist if responsedict[:action_name] toollist
errornote = "Your previous attempt has action_name that is not in the tool list" errornote = "Your previous attempt has action_name that is not in the tool list"
println("\nERROR SQLLLM decisionMaker(). Attempt $attempt/$maxattempt. $errornote --> $(responsedict[:action_name]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR SQLLLM decisionMaker(). Attempt $attempt/$maxattempt. $errornote --(not qualify response)--> $(responsedict[:action_name]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
end end
for i in toollist for i in toollist
if occursin(i, responsedict[:action_input]) if occursin(i, responsedict[:action_input])
errornote = "Your previous attempt has action_name in action_input which is not allowed" errornote = "Your previous attempt has action_name in action_input which is not allowed"
println("\nERROR SQLLLM decisionMaker(). Attempt $attempt/$maxattempt. $errornote --> $(responsedict[:action_input]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR SQLLLM decisionMaker(). Attempt $attempt/$maxattempt. $errornote --(not qualify response)--> $(responsedict[:action_input]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
end end
end end
@@ -721,7 +721,7 @@ function evaluator(state::T1, thoughtDict, text2textInstructLLM::Function, llmFo
if accepted_as_answer ["yes", "no"] if accepted_as_answer ["yes", "no"]
errornote = "Your previous attempt's accepted_as_answer has wrong format" errornote = "Your previous attempt's accepted_as_answer has wrong format"
println("\nERROR SQLLLM evaluator() Attempt $attempt/$maxattempt. $errornote --> $(responsedict[:accepted_as_answer]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR SQLLLM evaluator() Attempt $attempt/$maxattempt. $errornote --(not qualify response)--> $(responsedict[:accepted_as_answer]) ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
end end
@@ -1207,7 +1207,7 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
wine_name varchar(128) not null, wine_name varchar(128) not null,
winery varchar(128) not null, winery varchar(128) not null,
vintage integer not null, vintage integer not null,
region varchar(128) not null, region varchar(128) not null, -- A field used to store the name of a wine-producing region, such as Napa Valley (California), Bordeaux, Champagne, Tuscany, etc.
country varchar(128) not null, country varchar(128) not null,
wine_type varchar(128) not null, wine_type varchar(128) not null,
grape varchar(128) not null, grape varchar(128) not null,
@@ -1217,7 +1217,7 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
tannin integer, tannin integer,
acidity integer, acidity integer,
fizziness integer, fizziness integer,
tasting_notes text, tasting_notes text, -- A field used to record the distinctive flavors of wine such as floral, citrus, apple, earthy, daisy, etc.
note text, note text,
other_attributes jsonb, other_attributes jsonb,
@@ -1285,7 +1285,7 @@ function query(query::T, executeSQL::Function, text2textInstructLLM::Function;
multithread=false) multithread=false)
# compare all high value state answer then select the best one # compare all high value state answer then select the best one
if length(highValueState) > 0 if length(highValueState) > 1
# open("/appfolder/app/highValueState.json", "w") do io # open("/appfolder/app/highValueState.json", "w") do io
# JSON3.pretty(io, highValueState) # JSON3.pretty(io, highValueState)
# end # end

View File

@@ -1,60 +1,60 @@
""" """
Default system message template: # -------------------------------- Default system message template ------------------------------- #
<Your role> <Your role>
- You are a helpful assistant - You are a helpful assistant
</Your role> </Your role>
<Situation> <Situation>
- Describe the current situation - Describe the current situation
Ex. The world use enormous energy from non-sustainable sources. This leads to climate change. Ex. The world use enormous energy from non-sustainable sources. This leads to climate change.
</Situation> </Situation>
<Your vision> <Your vision>
- state your vision of how the situation will evolve, what would you want the situation to evolve into - state your vision of how the situation will evolve, what would you want the situation to evolve into
Ex. To be the leading innovator in sustainable technology by 2030, transforming global energy systems. Ex. To be the leading innovator in sustainable technology by 2030, transforming global energy systems.
</Your vision> </Your vision>
<Your mission> <Your mission>
- state the goalp - state the goal
Ex. Empowering communities through clean energy solutions to create a sustainable future. Ex. Empowering communities through clean energy solutions to create a sustainable future.
</Your mission> </Your mission>
<Your mission's objective includes> <Your mission's objective includes>
- Specific, measurable, and time-bound goals that directly support the mission. - Specific, measurable, and time-bound goals that directly support the mission.
Ex. Launch 50 solar-powered water purification systems in 3 regions by 2025. Ex. Launch 50 solar-powered water purification systems in 3 regions by 2025.
</Your mission's objective includes> </Your mission's objective includes>
<Your responsibility includes> <Your responsibility includes>
- state the mini goals that fall under your responsibility - state the mini goals that fall under your responsibility
</Your responsibility includes> </Your responsibility includes>
<Your responsibility does NOT includes> <Your responsibility does NOT includes>
- -
</Your responsibility does NOT includes> </Your responsibility does NOT includes>
<At each round of conversation, you will be given the following information> <At each round of conversation, you will be given the following information>
- -
</At each round of conversation, you will be given the following information> </At each round of conversation, you will be given the following information>
<You must follow the following policy> <You must follow the following policy>
- -
</You must follow the following policy> </You must follow the following policy>
<You should follow the following guidelines> <You should follow the following guidelines>
- -
</You should follow the following guidelines> </You should follow the following guidelines>
<You should then respond to the user with interleaving Comprehension, Plan, Action_name, Action_input> <You should then respond to the user with interleaving Comprehension, Plan, Action_name, Action_input>
Comprehension: State your comprehension about the current situation. Comprehension: State your comprehension about the current situation.
Plan: Given the current circumstances, outline a detailed, step-by-step plan to accomplish the task. Be specific. Plan: Given the current circumstances, outline a detailed, step-by-step plan to accomplish the task. Be specific.
Action_name: (Typically corresponds to the execution of the first step in your plan) Can be one of the following function names: Action_name: (Typically corresponds to the execution of the first step in your plan) Can be one of the following function names:
- CHATBOX which you can use to talk with the user. The input is your intentions for the dialogue. Be specific. - CHATBOX which you can use to talk with the user. The input is your intentions for the dialogue. Be specific.
- CHECKRESOURCES which you can use to check resources - CHECKRESOURCES which you can use to check resources
- IMPLEMENT which you can use to implement the solution - IMPLEMENT which you can use to implement the solution
Action_input: Detail the input for the action. Action_input: Detail the input for the action.
</You should then respond to the user with interleaving Comprehension, Plan, Action_name, Action_input> </You should then respond to the user with interleaving Comprehension, Plan, Action_name, Action_input>
<You should only respond in format as described below> <You should only respond in format as described below>
Comprehension: ... Comprehension: ...
Plan: ... Plan: ...
Action_name: ... Action_name: ...
Action_input: ... Action_input: ...
</You should only respond in format as described below> </You should only respond in format as described below>
<Here are some examples> <Here are some examples>
</Here are some examples> </Here are some examples>
Let's begin! Let's begin!
@@ -64,7 +64,7 @@ Default system message template:
Example: # ------------------------------------------- Example: ------------------------------------------- #
<Your profile> <Your profile>
- You are a founder of a tech startup - You are a founder of a tech startup