Compare commits

..

7 Commits

Author SHA1 Message Date
ton ddbb135b6b update 2026-07-17 12:22:56 +07:00
ton afda364484 update 2026-07-17 12:03:36 +07:00
ton af73d955eb Merge pull request 'v0.7.1' (#27) from v0.7.1 into main
Reviewed-on: #27
2026-07-17 03:28:17 +00:00
ton 39cf9a72a1 Merge pull request 'v0.7.1-fix_single_items_info_frontend' (#26) from v0.7.1-fix_single_items_info_frontend into v0.7.1
Reviewed-on: #26
2026-07-17 03:28:06 +00:00
ton 1c829ad854 update 2026-07-17 10:14:13 +07:00
ton da98baddb6 update 2026-07-17 10:06:32 +07:00
ton c5fbaabf42 Merge pull request 'v0.7.0' (#25) from v0.7.0 into main
Reviewed-on: #25
2026-07-17 00:03:01 +00:00
2 changed files with 37 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name = "YiemAgent"
uuid = "e012c34b-7f78-48e0-971c-7abb83b6f0a2"
version = "0.7.0"
version = "0.7.2"
authors = ["narawat lamaiin <narawat@outlook.com>"]
[deps]
+36 -9
View File
@@ -73,7 +73,7 @@ OrderedDict{String, Any} with 4 entries:
"action_result" => "1) winery: Terrazze dell Etna, wine_name: Rose Brut.
```
"""
function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
) where {T<:agent}
@info "YiemAgent decisionMaker() start " @__LINE__
# lessonDict = copy(JSON.parsefile("lesson.json"))
@@ -187,7 +187,14 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
@info "YiemAgent decisionMaker() end " @__LINE__
return responsedict
end
error("DecisionMaker failed to generate a thought ", response)
# in case decisionMaker failed, force to use generatechat!()
responsedict = OrderedDict(
"plan"=> "N/A",
"action_name"=> "CHAT_BOX",
"action_input"=> "N/A"
)
return responsedict
end
@@ -395,15 +402,21 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
items_info = []
send_item_ind = [] # index of the item being send to frontend
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)
push!(items_info, deepcopy(item))
push!(send_item_ind, i)
end
end
end
# remove sent items
deleteat!(a.memory["shortmem"]["items_info"], send_item_ind)
end
response_to_frontend = Dict{String, Any}(
"role" => "assistant",
"content" => [
@@ -431,15 +444,21 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
items_info = []
send_item_ind = [] # index of the item being send to frontend
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)
push!(items_info, deepcopy(item))
push!(send_item_ind, i)
end
end
end
# remove sent items
deleteat!(a.memory["shortmem"]["items_info"], send_item_ind)
end
response_to_frontend = Dict{String, Any}(
"role" => "assistant",
"content" => [
@@ -527,7 +546,14 @@ function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict,
result_raw = nothing
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"
@@ -784,6 +810,7 @@ function generatechat!(a::T; maxattempt::Integer=10
@info "YiemAgent generatechat!() end " @__LINE__
return (thoughtdict=responsedict, result_raw=responsedict["action_input"])
end
@info "YiemAgent generatechat() failed to generate a thought " @__LINE__
error("YiemAgent generatechat() failed to generate a thought ", response)
end