This commit is contained in:
2026-07-27 17:43:11 +07:00
parent 4397ec5fb3
commit 37ff68c963
2 changed files with 21 additions and 37 deletions
+17 -33
View File
@@ -76,35 +76,7 @@ OrderedDict{String, Any} with 4 entries:
function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
) where {T<:agent}
@info "YiemAgent decisionMaker() start " @__LINE__
# lessonDict = copy(JSON.parsefile("lesson.json"))
# lesson =
# if isempty(lessonDict)
# ""
# else
# lessons = Dict{String, Any}()
# for (k, v) in lessonDict
# lessons[k] = lessonDict[k][:lesson]
# end
# """
# You have attempted to help the user before and failed, either because your reasoning for the
# recommendation was incorrect or your response did not exactly match the user expectation.
# The following lesson(s) give a plan to avoid failing to help the user in the same way you
# did previously. Use them to improve your strategy to help the user.
# Here are some lessons in JSON format:
# $(JSON.json(lessons))
# When providing the thought and action for the current trial, that into account these failed
# trajectories and make sure not to repeat the same mistakes and incorrect answers.
# """
# end
# recentevents_ind = GeneralUtils.recentElementsIndex(
# length(a.memory["events"]), recentevents; includelatest=true)
requiredKeys = ["plan", "action_name", "action_input"]
context =
"""
<internal_context_for_assistant>
@@ -173,7 +145,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
"properties"=> Dict(
"think"=> Dict(
"type"=> "string",
"description"=> "your thought"
"description"=> "Your step-by-step reasoning process. Explain why you are choosing this action."
),
"action_name"=> Dict(
"type"=> "string",
@@ -181,8 +153,13 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
"description"=> "one of the available actions"
),
"action_input"=> Dict(
"type"=> "string",
"description"=> "action's input"
"type"=> "object",
"properties"=> Dict(
"dialogue"=> Dict("type"=> "string", "description"=> "for CHAT_BOX"),
"query"=> Dict("type"=> "string", "description"=> "for SEARCH_WINE_DATABASE"),
"present_guide"=> Dict("type"=> "null", "description"=> "for WINE_PRESENTATION_GUIDELINE"),
"endconv_guide"=> Dict("type"=> "null", "description"=> "for END_CONVER_GUIDELINE"),
)
),
),
"required"=> ["think", "action_name", "action_input"],
@@ -208,6 +185,13 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
end
responsedict = JSON.parse(response)
# println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# pprintln(responsedict)
# for decision that use a single action. make it simpler
for (k, v) in responsedict["action_input"]
responsedict["action_input"] = v
end
if occursin("CHAT_BOX", responsedict["action_input"])
println("\nERROR YiemAgent decisionMaker() --(not qualify response)> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
@@ -220,8 +204,8 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
continue
end
# println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# pprintln(responsedict)
println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
pprintln(responsedict)
@info "YiemAgent decisionMaker() end " @__LINE__
return responsedict
end