This commit is contained in:
2026-07-14 18:08:36 +07:00
parent fa338dd0f8
commit a798cd119e
9 changed files with 186 additions and 60 deletions
+27 -19
View File
@@ -68,7 +68,7 @@ julia> result = decisionMaker(agent)
OrderedDict{String, Any} with 4 entries:
"plan" => "The user provided an image of a sparkling white wine (Asolo Prosecco Bella Principessa from Italy) and requested a search for similar wines in the inventory. According to store guidelines, I must st…
"action_name" => "CHECK_WINE"
"action_name" => "SEARCH_WINE_DATABASE"
"action_input" => "Sparkling white wine from Italy"
"action_result" => "1) winery: Terrazze dell Etna, wine_name: Rose Brut.
```
@@ -177,7 +177,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
continue
end
# if responsedict["action_name"] ∉ ["CHAT_BOX", "CHECK_WINE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
# if responsedict["action_name"] ∉ ["CHAT_BOX", "SEARCH_WINE_DATABASE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
# errornote = "Your previous attempt didn't use the given functions"
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# continue
@@ -392,7 +392,7 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
end
@info "YiemAgent conversation() 2-3 think count $loopcount " @__LINE__
thoughtdict, _ = think(a)
thoughtdict, result_raw = think(a)
if thoughtdict["action_name"] ["CHAT_BOX"]
@info "YiemAgent conversation() 2-4 think count $loopcount " @__LINE__
assistant_response = Dict{String, Any}(
@@ -401,7 +401,25 @@ function conversation(a::sommelier; userinput::Union{Dict{String, Any}, JSON.Obj
)
addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
return thoughtdict["action_input"]
# elseif thoughtdict["action_name"] ∈ ["CHAT_BOX"]
# @info "YiemAgent conversation() 2-4 think count $loopcount " @__LINE__
# assistant_response = Dict{String, Any}(
# "role" => "assistant",
# "content" => [
# Dict("type" => "text", "text" => thoughtdict["action_input"]),
# Dict( #WORKING put 1st image here
# "type" => "image_url",
# "image_url" => Dict("url" => image1_data_uri)
# ),
# Dict( #WORKING put 2nd image here
# "type" => "image_url",
# "image_url" => Dict("url" => image2_data_uri)
# ),
# ]
# )
# addNewMessage(a, "assistant", assistant_response; maximumMsg=maximumMsg)
return thoughtdict["action_input"] #XXX change output from string to dict
else
action_name = thoughtdict["action_name"]
action_input = thoughtdict["action_input"]
@@ -452,27 +470,17 @@ function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict,
elseif thoughtdict["action_name"] ["WINE_PRESENTATION_GUIDELINE"]
@info "YiemAgent think() 4 " @__LINE__
thoughtdict, result_raw = wine_presentation_guideline!(a, thoughtdict)
elseif thoughtdict["action_name"] == "CHECK_WINE"
elseif thoughtdict["action_name"] == "SEARCH_WINE_DATABASE"
@info "YiemAgent think() 5 " @__LINE__
thoughtdict, result_raw = checkwine!(a, thoughtdict; useSQLLLM=false)
thoughtdict, result_raw = search_wine_database!(a, thoughtdict; useSQLLLM=true)
#WORKING result_raw will be a df. i need to get images so i can send to frontend
else
@info "YiemAgent think() 6 " @__LINE__
error("condition is not defined ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
end
# max_ind =
# if length(a.memory["shortmem"]) == 0
# 0
# else
# k = keys(a.memory["shortmem"])
# maximum(parse.(Int, k))
# end
# a.memory["shortmem"]["$(max_ind + 1)"] = thoughtdict
pprintln(thoughtdict)
println("\n")
@show thoughtdict
@info "YiemAgent think() 7 " @__LINE__
return (thoughtdict=thoughtdict, result_raw=result_raw)
end
@@ -700,7 +708,7 @@ function generatechat!(a::T; maxattempt::Integer=10
continue
end
# if responsedict["action_name"] ∉ ["CHAT_BOX", "CHECK_WINE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
# if responsedict["action_name"] ∉ ["CHAT_BOX", "SEARCH_WINE_DATABASE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"]
# errornote = "Your previous attempt didn't use the given functions"
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# continue