This commit is contained in:
2026-07-10 17:45:58 +07:00
parent afeb4c7aef
commit 9ff0b48eec
4 changed files with 31 additions and 31 deletions
+18 -18
View File
@@ -358,7 +358,7 @@ message => Dict(
function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Object{String, Any}},
maximumMsg=50, max_think_loop::Integer=3)
@info "YiemAgent conversation() 1" @__LINE__
@info "YiemAgent conversation() 1 " @__LINE__
userinput = GeneralUtils.dictify(userinput; keytype=String, sort_order=["text"])
# find text in usermsg
@@ -374,7 +374,7 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
clearhistory(a)
return "Okay. What shall we talk about?"
else
@info "YiemAgent conversation() 2" @__LINE__
@info "YiemAgent conversation() 2 " @__LINE__
# add usermsg to a.chathistory but how do I handle images?
addNewMessage(a, "user", userinput; maximumMsg=maximumMsg)
@@ -382,10 +382,17 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
loopcount = 0
while true
loopcount += 1
@info "YiemAgent conversation() 2-0 count $loopcount" @__LINE__
if loopcount > max_think_loop
@info "YiemAgent conversation() 2-1 think count $loopcount " @__LINE__
r = generatechat(a)
@info "YiemAgent conversation() 2-2 think count $loopcount " @__LINE__
return r
end
@info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__
thoughtdict, _ = think(a)
if thoughtdict["action_name"] ["CHAT_BOX"]
@info "YiemAgent conversation() 2-1" @__LINE__
@info "YiemAgent conversation() 2-4 think count $loopcount " @__LINE__
assistant_response = Dict{String, Any}(
"role" => "assistant",
"content" => [Dict("type" => "text", "text" => thoughtdict["action_input"]),]
@@ -393,13 +400,6 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
return thoughtdict["action_input"]
end
if loopcount > max_think_loop
@info "YiemAgent conversation() 2-2" @__LINE__
r = generatechat(a)
@info "YiemAgent conversation() 2-3" @__LINE__
return r
end
end
end
end
@@ -419,29 +419,29 @@ julia>
function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict, Any}} where {T<:agent}
# a.memory[:recap] = generateSituationReport(a, a.context["text"2textInstructLLM]; skiprecent=0)
thoughtdict = decisionMaker(a)
@info "YiemAgent think() 1" @__LINE__
@info "YiemAgent think() 1 " @__LINE__
# pprintln(thoughtdict)
result_raw = nothing
if thoughtdict["action_name"] ["CHAT_BOX"]
@info "YiemAgent think() 2" @__LINE__
@info "YiemAgent think() 2 " @__LINE__
thoughtdict, result_raw = chatbox!(a, thoughtdict)
elseif thoughtdict["action_name"] == "END_CONVER_GUIDELINE"
@info "YiemAgent think() 3" @__LINE__
@info "YiemAgent think() 3 " @__LINE__
thoughtdict, result_raw = end_conversation_guideline!(a, thoughtdict)
elseif thoughtdict["action_name"] ["WINE_PRESENTATION_GUIDELINE"]
@info "YiemAgent think() 4" @__LINE__
@info "YiemAgent think() 4 " @__LINE__
thoughtdict, result_raw = wine_presentation_guideline!(a, thoughtdict)
elseif thoughtdict["action_name"] == "CHECK_WINE"
@info "YiemAgent think() 5" @__LINE__
@info "YiemAgent think() 5 " @__LINE__
thoughtdict, result_raw = checkwine!(a, thoughtdict)
else
@info "YiemAgent think() 6" @__LINE__
@info "YiemAgent think() 6 " @__LINE__
error("condition is not defined ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
end
@@ -454,7 +454,7 @@ function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict,
end
a.memory["shortmem"]["$(max_ind + 1)"] = thoughtdict
@info "YiemAgent think() 7" @__LINE__
@info "YiemAgent think() 7 " @__LINE__
pprintln(thoughtdict)
return (thoughtdict=thoughtdict, result_raw=result_raw)
end