v0.7.1-fix_single_items_info_frontend #26
+26
-7
@@ -395,15 +395,21 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
|
|||||||
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
||||||
|
|
||||||
items_info = []
|
items_info = []
|
||||||
|
send_item_ind = [] # index of the item being send to frontend
|
||||||
if haskey(a.memory["shortmem"], "items_info")
|
if haskey(a.memory["shortmem"], "items_info")
|
||||||
|
|
||||||
for (i, item) in enumerate(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"])
|
if haskey(item, "wine_name") && occursin(item["wine_name"], thoughtdict["action_input"])
|
||||||
push!(items_info, item)
|
push!(items_info, deepcopy(item))
|
||||||
deleteat!(a.memory["shortmem"]["items_info"], i)
|
push!(send_item_ind, i)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
# remove sent items
|
||||||
|
deleteat!(a.memory["shortmem"]["items_info"], send_item_ind)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
response_to_frontend = Dict{String, Any}(
|
response_to_frontend = Dict{String, Any}(
|
||||||
"role" => "assistant",
|
"role" => "assistant",
|
||||||
"content" => [
|
"content" => [
|
||||||
@@ -431,15 +437,21 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
|
|||||||
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
|
||||||
|
|
||||||
items_info = []
|
items_info = []
|
||||||
|
send_item_ind = [] # index of the item being send to frontend
|
||||||
if haskey(a.memory["shortmem"], "items_info")
|
if haskey(a.memory["shortmem"], "items_info")
|
||||||
|
|
||||||
for (i, item) in enumerate(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"])
|
if haskey(item, "wine_name") && occursin(item["wine_name"], thoughtdict["action_input"])
|
||||||
push!(items_info, item)
|
push!(items_info, deepcopy(item))
|
||||||
deleteat!(a.memory["shortmem"]["items_info"], i)
|
push!(send_item_ind, i)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
# remove sent items
|
||||||
|
deleteat!(a.memory["shortmem"]["items_info"], send_item_ind)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
response_to_frontend = Dict{String, Any}(
|
response_to_frontend = Dict{String, Any}(
|
||||||
"role" => "assistant",
|
"role" => "assistant",
|
||||||
"content" => [
|
"content" => [
|
||||||
@@ -527,7 +539,14 @@ function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict,
|
|||||||
result_raw = nothing
|
result_raw = nothing
|
||||||
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
if thoughtdict["action_name"] ∈ ["CHAT_BOX"]
|
||||||
|
|
||||||
thoughtdict, result_raw = generatechat!(a)
|
# sometime CHAT_BOX input is too short.
|
||||||
|
# if thoughtdict["action_input] < 20 character, use generatechat!()
|
||||||
|
if length(thoughtdict["action_input"]) < 20
|
||||||
|
thoughtdict, result_raw = generatechat!(a)
|
||||||
|
else
|
||||||
|
thoughtdict["action_result"] = "Action result is the next user dialogue."
|
||||||
|
result_raw = thoughtdict["action_input"]
|
||||||
|
end
|
||||||
|
|
||||||
elseif thoughtdict["action_name"] == "END_CONVER_GUIDELINE"
|
elseif thoughtdict["action_name"] == "END_CONVER_GUIDELINE"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user