This commit is contained in:
narawat lamaiin
2025-07-14 19:33:12 +07:00
parent bad2ca35ed
commit 8a9c9606c7
3 changed files with 38 additions and 29 deletions
+15 -15
View File
@@ -158,7 +158,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
# end
# recentrecap = GeneralUtils.dictToString_noKey(_recentrecap)
# similarDecision = a.func[:similarSommelierDecision](recentrecap)
# similarDecision = a.context[:similarSommelierDecision](recentrecap)
similarDecision = nothing #CHANGE
if similarDecision !== nothing
@@ -234,7 +234,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
println("\nYiemAgent decisionMaker() attempt $attempt/$maxattempt ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
end
# QandA = generatequestion(a, a.func[:text2textInstructLLM], timeline)
# QandA = generatequestion(a, a.context[:text2textInstructLLM], timeline)
context =
"""
@@ -285,7 +285,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
# add info
prompt = prompt * context
response = a.func[:text2textInstructLLM](prompt; senderId=a.id)
response = a.context.text2textInstructLLM(prompt; senderId=a.id)
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
response = GeneralUtils.remove_french_accents(response)
think, response = GeneralUtils.extractthink(response)
@@ -468,7 +468,7 @@ end
# end
# recentrecap = GeneralUtils.dictToString_noKey(_recentrecap)
# # similarDecision = a.func[:similarSommelierDecision](recentrecap)
# # similarDecision = a.context[:similarSommelierDecision](recentrecap)
# similarDecision = nothing #CHANGE
# if similarDecision !== nothing
@@ -500,7 +500,7 @@ end
# println("\nYiemAgent decisionMaker() attempt $attempt/10 ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# end
# QandA = generatequestion(a, a.func[:text2textInstructLLM]; recent=3)
# QandA = generatequestion(a, a.context[:text2textInstructLLM]; recent=3)
# systemmsg =
# """
# Your name is $(a.name). You are a helpful English-speaking assistant, acting as a polite, website-based sommelier for $(a.retailername)'s wine store.
@@ -601,7 +601,7 @@ end
# # change qwen format put in model format
# prompt = GeneralUtils.formatLLMtext(unformatPrompt, "qwen3")
# response = a.func[:text2textInstructLLM](prompt)
# response = a.context[:text2textInstructLLM](prompt)
# response = GeneralUtils.remove_french_accents(response)
# response = replace(response, "**"=>"")
# response = replace(response, "***"=>"")
@@ -838,7 +838,7 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
println("")
println(prompt)
response = a.func[:text2textInstructLLM](prompt; senderId=a.id)
response = a.context.text2textInstructLLM(prompt; senderId=a.id)
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
response = GeneralUtils.remove_french_accents(response)
# response = replace(response, '$'=>"USD")
@@ -1067,7 +1067,7 @@ julia>
# Signature
"""
function think(a::T)::NamedTuple{(:actionname, :result),Tuple{String,String}} where {T<:agent}
# a.memory[:recap] = generateSituationReport(a, a.func[:text2textInstructLLM]; skiprecent=0)
# a.memory[:recap] = generateSituationReport(a, a.context[:text2textInstructLLM]; skiprecent=0)
thoughtDict = decisionMaker(a)
actionname = thoughtDict[:actionname]
@@ -1272,7 +1272,7 @@ function presentbox(a::sommelier, thoughtDict; maxtattempt::Integer=10, recentev
# add info
prompt = prompt * context
response = a.func[:text2textInstructLLM](prompt; senderId=a.id)
response = a.context.text2textInstructLLM(prompt; senderId=a.id)
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
response = GeneralUtils.remove_french_accents(response)
# response = replace(response, '$'=>"USD")
@@ -1453,7 +1453,7 @@ end
# # add info
# prompt = prompt * context
# response = a.func[:text2textInstructLLM](prompt; senderId=a.id)
# response = a.context[:text2textInstructLLM](prompt; senderId=a.id)
# response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
# response = GeneralUtils.remove_french_accents(response)
# # response = replace(response, '$'=>"USD")
@@ -1634,7 +1634,7 @@ function generatechat(a::sommelier, thoughtDict; maxattempt::Integer=10)
for attempt in 1:maxattempt
# if attempt > 1 # use to prevent LLM generate the same respond over and over
# println("\nYiemAgent generatchat() attempt $attempt/10 ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# yourthought1 = paraphrase(a.func[:text2textInstructLLM], yourthought)
# yourthought1 = paraphrase(a.context[:text2textInstructLLM], yourthought)
# else
# yourthought1 = yourthought
# end
@@ -1658,7 +1658,7 @@ function generatechat(a::sommelier, thoughtDict; maxattempt::Integer=10)
# add info
prompt = prompt * context
response = a.func[:text2textInstructLLM](prompt; senderId=a.id)
response = a.context.text2textInstructLLM(prompt; senderId=a.id)
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
response = GeneralUtils.remove_french_accents(response)
# response = replace(response, '$'=>"USD")
@@ -1807,7 +1807,7 @@ function generatechat(a::companion; recentevents::Integer=10,
prompt = replace(_prompt, "|>user"=>"|>$(converPartnerName)")
prompt = replace(prompt, "|>assistant"=>"|>$(a.name)")
response = a.func[:text2textInstructLLM](prompt; llmkwargs=llmkwargs, senderId=a.id)
response = a.context.text2textInstructLLM(prompt; llmkwargs=llmkwargs, senderId=a.id)
response = replace(response, "<|im_start|>"=> "")
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
think, response = GeneralUtils.extractthink(response)
@@ -1863,7 +1863,7 @@ function generatechat(a::virtualcustomer;
# add info
prompt = prompt * context
response = a.func[:text2textInstructLLM](prompt; llmkwargs=llmkwargs, senderId=a.id)
response = a.context.text2textInstructLLM(prompt; llmkwargs=llmkwargs, senderId=a.id)
response = replace(response, "<|im_start|>"=> "")
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
think, response = GeneralUtils.extractthink(response)
@@ -2291,7 +2291,7 @@ function detectWineryName(a, text)
# put in model format
prompt = GeneralUtils.formatLLMtext(_prompt, a.llmFormatName)
response = a.func[:text2textInstructLLM](prompt; senderId=a.id)
response = a.context.text2textInstructLLM(prompt; senderId=a.id)
response = GeneralUtils.deFormatLLMtext(response, a.llmFormatName)
think, response = GeneralUtils.extractthink(response)
println("\ndetectWineryName() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")