This commit is contained in:
2026-07-16 23:13:18 +07:00
parent 87bc6a46a1
commit e718cc4a5c
+37 -6
View File
@@ -153,6 +153,9 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
println("\nERROR YiemAgent decisionMaker() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR YiemAgent decisionMaker() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue continue
end end
else
println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)-> $responsedict", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
continue
end end
@info "YiemAgent decisionMaker() 8 " @__LINE__ @info "YiemAgent decisionMaker() 8 " @__LINE__
# check whether all answer's key points are in responsedict # check whether all answer's key points are in responsedict
@@ -356,7 +359,7 @@ message => Dict(
function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Object{String, Any}}, function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Object{String, Any}},
maximumMsg=50, max_think_loop::Integer=3) maximumMsg=50, max_think_loop::Integer=3)
@info "YiemAgent conversation() 1 " @__LINE__ @info "YiemAgent conversation() 0 " @__LINE__
userinput = GeneralUtils.dictify(userinput; keytype=String, sort_order=["text"]) userinput = GeneralUtils.dictify(userinput; keytype=String, sort_order=["text"])
# find text in usermsg # find text in usermsg
@@ -372,7 +375,7 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
clearhistory(a) clearhistory(a)
return "Okay. What shall we talk about?" return "Okay. What shall we talk about?"
else else
@info "YiemAgent conversation() 2 " @__LINE__ @info "YiemAgent conversation() 1 " @__LINE__
# add usermsg to a.chathistory but how do I handle images? # add usermsg to a.chathistory but how do I handle images?
addNewMessage(a, "user", userinput; maximumMsg=maximumMsg) addNewMessage(a, "user", userinput; maximumMsg=maximumMsg)
@@ -381,10 +384,38 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
while true while true
loopcount += 1 loopcount += 1
if loopcount > max_think_loop if loopcount > max_think_loop
@info "YiemAgent conversation() 2-1 think count $loopcount " @__LINE__ @info "YiemAgent conversation() 1-1 think count $loopcount " @__LINE__
r = generatechat!(a) thoughtdict, result_raw = generatechat!(a)
@info "YiemAgent conversation() 2-2 think count $loopcount " @__LINE__ @info "YiemAgent conversation() 1-2 think count $loopcount " @__LINE__
return r
assistant_response = Dict{String, Any}(
"role" => "assistant",
"content" => [Dict("type" => "text", "text" => thoughtdict["action_input"]),]
)
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
items_info = []
if haskey(a.memory["shortmem"], "items_info")
for (i, item) in enumerate(a.memory["shortmem"]["items_info"])
if haskey(item, "wine_name") && occursin(item["wine_name"], thoughtdict["action_input"])
push!(items_info, item)
deleteat!(a.memory["shortmem"]["items_info"], i)
end
end
end
response_to_frontend = Dict{String, Any}(
"role" => "assistant",
"content" => [
Dict("type" => "text", "text" => thoughtdict["action_input"]),
Dict(
"type" => "items_info",
"items_info" => items_info
),
]
)
@info "YiemAgent conversation() 1-3 think count $loopcount " @__LINE__
return response_to_frontend
end end
@info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__ @info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__