This commit is contained in:
narawat lamaiin
2025-04-25 21:13:12 +07:00
parent b8fd331c1a
commit d9c842bba5
2 changed files with 15 additions and 8 deletions

View File

@@ -230,8 +230,9 @@ function decisionMaker(state::T1, context, text2textInstructLLM::Function,
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="qwen")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
response = text2textInstructLLM(prompt; llmkwargs=llmkwargs)
response = GeneralUtils.deFormatLLMtext(response, "granite3")
# LLM tends to generate observation given that it is in the input
response =
@@ -448,12 +449,13 @@ function evaluator(state::T1, text2textInstructLLM::Function
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="qwen")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
header = ["Trajectory_evaluation:", "Answer_evaluation:", "Accepted_as_answer:", "Score:", "Suggestion:"]
dictkey = ["trajectory_evaluation", "answer_evaluation", "accepted_as_answer", "score", "suggestion"]
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, "granite3")
# sometime LLM output something like **Comprehension**: which is not expected
response = replace(response, "**"=>"")
@@ -603,7 +605,7 @@ function reflector(config::T1, state::T2)::String where {T1<:AbstractDict, T2<:A
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="qwen")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
externalService = config[:externalservice][:text2textinstruct]
# apply LLM specific instruct format
@@ -1176,10 +1178,11 @@ function generatequestion(state::T1, context, text2textInstructLLM::Function;
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="qwen")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
try
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, "granite3")
# check if response is valid
q_number = count("Q", response)

View File

@@ -406,9 +406,10 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM:
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="llama3instruct")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
try
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, "granite3")
header = ["Comprehension:", "Plan:", "Code:"]
dictkey = ["comprehension", "plan", "code"]
@@ -627,12 +628,13 @@ function extractContent_dataframe(df::DataFrame, text2textInstructLLM::Function,
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="llama3instruct")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
header = ["About_resulting_table:", "Search_summary:"]
dictkey = ["about_resulting_table", "search_summary"]
for i in 1:5
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, "granite3")
kw = []
# use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list
@@ -762,13 +764,14 @@ function getTableNameFromSQL(sql::T, text2textInstructLLM::Function)::Vector{Str
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="llama3instruct")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
header = ["Table_name:"]
dictkey = ["table_name"]
for attempt in 1:5
try
response = text2textInstructLLM(prompt, modelsize="medium")
response = GeneralUtils.deFormatLLMtext(response, "granite3")
responsedict = GeneralUtils.textToDict(response, header;
dictKey=dictkey, symbolkey=true)
response = copy(JSON3.read(responsedict[:table_name]))
@@ -914,7 +917,7 @@ function compareState(question::String, highValueStateList::Vector{T},
]
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt; formatname="llama3instruct")
prompt = GeneralUtils.formatLLMtext(_prompt, "granite3")
header = ["Comparison:", "Rationale:", "Selected_response_number:"]
dictkey = ["comparison", "rationale", "selected_response_number"]
@@ -924,6 +927,7 @@ function compareState(question::String, highValueStateList::Vector{T},
# sometime LLM output something like **Comprehension**: which is not expected
response = replace(response, "**"=>"")
response = replace(response, "***"=>"")
response = GeneralUtils.deFormatLLMtext(response, "granite3")
# make sure every header is in the response
for i in header