update
This commit is contained in:
+37
-6
@@ -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())")
|
||||
continue
|
||||
end
|
||||
else
|
||||
println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)-> $responsedict", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
||||
continue
|
||||
end
|
||||
@info "YiemAgent decisionMaker() 8 " @__LINE__
|
||||
# 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}},
|
||||
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"])
|
||||
|
||||
# find text in usermsg
|
||||
@@ -372,7 +375,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() 1 " @__LINE__
|
||||
# add usermsg to a.chathistory but how do I handle images?
|
||||
addNewMessage(a, "user", userinput; maximumMsg=maximumMsg)
|
||||
|
||||
@@ -381,10 +384,38 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
|
||||
while true
|
||||
loopcount += 1
|
||||
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
|
||||
@info "YiemAgent conversation() 1-1 think count $loopcount " @__LINE__
|
||||
thoughtdict, result_raw = generatechat!(a)
|
||||
@info "YiemAgent conversation() 1-2 think count $loopcount " @__LINE__
|
||||
|
||||
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
|
||||
|
||||
@info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__
|
||||
|
||||
Reference in New Issue
Block a user