update #37

Merged
ton merged 1 commits from v0.7.4-add_vector_search into v0.7.4 2026-07-27 09:55:11 +00:00
3 changed files with 48 additions and 77 deletions
+44 -72
View File
@@ -141,7 +141,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
"action_name": { "action_name": {
"type": "string", "type": "string",
"enum": ["search_web", "get_weather", "calculate_math"], "enum": ["search_web", "get_weather", "calculate_math"],
"description": "The exact name of the tool to execute." "description": "The exact name of the action to execute."
}, },
"action_input": { "action_input": {
"type": "object", "type": "object",
@@ -171,11 +171,21 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
"schema"=> Dict( "schema"=> Dict(
"type"=> "object", "type"=> "object",
"properties"=> Dict( "properties"=> Dict(
"plan"=> Dict("type"=> "string"), "think"=> Dict(
"action_name"=> Dict("type"=> "string"), "type"=> "string",
"action_input"=> Dict("type"=> "string"), "description"=> "your thought"
),
"action_name"=> Dict(
"type"=> "string",
"enum"=> ["CHAT_BOX", "SEARCH_WINE_DATABASE", "WINE_PRESENTATION_GUIDELINE", "END_CONVER_GUIDELINE"],
"description"=> "one of the available actions"
),
"action_input"=> Dict(
"type"=> "string",
"description"=> "action's input"
),
), ),
"required"=> ["plan", "action_name", "action_input"], "required"=> ["think", "action_name", "action_input"],
"additionalProperties"=> false "additionalProperties"=> false
) )
) )
@@ -191,46 +201,24 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
for attempt in 1:maxattempt for attempt in 1:maxattempt
response = a.context.text2textInstructLLM(a.id, msg) response = a.context.text2textInstructLLM(a.id, msg)
response = GeneralUtils.remove_french_accents(response) response = GeneralUtils.remove_french_accents(response)
# think, response = GeneralUtils.extractthink(response)
# dollar sign in Julia means string interpolation # dollar sign in Julia means string interpolation
while occursin('$', response) while occursin('$', response)
response = replace(response, '$' => "USD") response = replace(response, '$' => "USD")
end end
# responsedict = nothing
# try
# responsedict = Serde.parse_yaml(response)
# catch e
# println("\nERROR YiemAgent decisionMaker() Error: $e --(not qualify response)-> $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
# continue
# end
# # check whether all answer's key points are in responsedict
# println("\n---")
# println(responsedict)
# println("---\n")
# ispass, errormsg = GeneralUtils.checkAgentResponse_JSON(responsedict, requiredKeys)
# if !ispass
# errornote = errormsg
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)-> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
# continue
# end
responsedict = JSON.parse(response) responsedict = JSON.parse(response)
if responsedict["action_input"] == "CHAT_BOX" && if occursin("CHAT_BOX", responsedict["action_input"])
occursin("similar", responsedict["action_input"]) println("\nERROR YiemAgent decisionMaker() --(not qualify response)> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
continue continue
end end
# if responsedict["action_name"] ∉ ["CHAT_BOX", "SEARCH_WINE_DATABASE", "PRESENT_WINE_GUIDELINE", "END_CONVER_GUIDELINE"] if responsedict["action_name"] ["WINE_PRESENTATION_GUIDELINE", "END_CONVER_GUIDELINE"] &&
# errornote = "Your previous attempt didn't use the given functions" length(responsedict["action_input"]) < 20
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)--> $(responsedict["action_name"])", @__FILE__, ":", @__LINE__, " $(Dates.now())") println("\nERROR YiemAgent decisionMaker() --(not qualify response)> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
# continue continue
# end end
# println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())") # println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# pprintln(responsedict) # pprintln(responsedict)
@@ -240,7 +228,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
# in case decisionMaker failed, force to use generatechat!() # in case decisionMaker failed, force to use generatechat!()
responsedict = OrderedDict( responsedict = OrderedDict(
"plan"=> "N/A", "think"=> "N/A",
"action_name"=> "CHAT_BOX", "action_name"=> "CHAT_BOX",
"action_input"=> "N/A" "action_input"=> "N/A"
) )
@@ -776,9 +764,9 @@ function generatechat!(a::T; maxattempt::Integer=10
- Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store. - Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store.
- Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store. - Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store.
# you should then respond to the user with interleaving plan, action_name, action_input in JSON format # you should then respond to the user with interleaving think, action_name, action_input in JSON format
1) "plan", Based on the current situation, state a complete action plan to complete the task and rationale. Be specific. 1) "think", Your step-by-step reasoning process. Explain why you are choosing this action.
2) "action_name", action_name must be CHAT_BOX. 2) "action_name", Can be one of the available_actions name.
3) "action_input", Dialogue you want to chat with the user according to your plan. 3) "action_input", Dialogue you want to chat with the user according to your plan.
After the action is executed you gets "action_result". It is the output from the action you selected. After the action is executed you gets "action_result". It is the output from the action you selected.
@@ -814,20 +802,21 @@ function generatechat!(a::T; maxattempt::Integer=10
"schema"=> Dict( "schema"=> Dict(
"type"=> "object", "type"=> "object",
"properties"=> Dict( "properties"=> Dict(
"plan"=> Dict( "think"=> Dict(
"type"=> "string", "type"=> "string",
"description" => "Based on the current situation, state a complete action plan to complete the task and rationale. Be specific.", "description" => "Your step-by-step reasoning process. Explain why you are choosing this action.",
), ),
"action_name"=> Dict( "action_name"=> Dict(
"type"=> "string", "type"=> "string",
"description" => "action_name must be CHAT_BOX", "enum"=> ["CHAT_BOX"],
"description" => "one of the available actions",
), ),
"action_input"=> Dict( "action_input"=> Dict(
"type"=> "string", "type"=> "string",
"description" => "Dialogue you want to chat with the user according to your plan.", "description" => "Dialogue you want to chat with the user according to your plan.",
), ),
), ),
"required"=> ["plan", "action_name", "action_input"], "required"=> ["think", "action_name", "action_input"],
"additionalProperties"=> false "additionalProperties"=> false
) )
) )
@@ -841,43 +830,26 @@ function generatechat!(a::T; maxattempt::Integer=10
) )
response = a.context.text2textInstructLLM(a.id, msg) response = a.context.text2textInstructLLM(a.id, msg)
response = GeneralUtils.clean_json_response(response)
response = GeneralUtils.remove_french_accents(response) response = GeneralUtils.remove_french_accents(response)
think, response = GeneralUtils.extractthink(response)
response = strip(response) # dollar sign in Julia means string interpolation
while occursin('$', response)
response = replace(response, '$' => "USD")
end
responsedict = nothing responsedict = JSON.parse(response)
if occursin(requiredKeys[2], response)
try if occursin("CHAT_BOX", responsedict["action_input"]) ||
_responsedict = JSON.parse(response) length(responsedict["action_input"]) < 20
responsedict = GeneralUtils.dictify(_responsedict; keytype=String, sort_order=requiredKeys) println("\nERROR YiemAgent generatechat() --(not qualify response)> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
catch
println("\nERROR YiemAgent generatechat() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
continue
end
else
println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
continue continue
end end
println("\nYiem generatechat!() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
pprintln(responsedict)
responsedict["action_result"] = "Action result is the next user dialogue."
@info "YiemAgent generatechat!() end " @__LINE__
# check whether all answer's key points are in responsedict
ispass, errormsg = GeneralUtils.checkAgentResponse_JSON(responsedict, requiredKeys)
if !ispass
errornote = errormsg
println("\nERROR YiemAgent generatechat() $errornote --(not qualify response)> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
continue
end
# 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
# end
# println("\nYiem decisionMaker() ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
# pprintln(responsedict)
responsedict["action_result"] = "Action result is the next user dialogue." responsedict["action_result"] = "Action result is the next user dialogue."
@info "YiemAgent generatechat!() end " @__LINE__ @info "YiemAgent generatechat!() end " @__LINE__
return (thoughtdict=responsedict, result_raw=responsedict["action_input"]) return (thoughtdict=responsedict, result_raw=responsedict["action_input"])
-1
View File
@@ -846,7 +846,6 @@ function wine_search_term_classification(a::T, searchterm::String,
push!(vector_search, entry) push!(vector_search, entry)
end end
end end
responsedict = hard_conditions
println("") println("")
@show responsedict @show responsedict
+4 -4
View File
@@ -199,10 +199,10 @@ function sommelier(
- Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store. - Processing sales orders or engaging in any other sales-related activities. These are the job of our sales team at the store.
- Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store. - Answering questions or offering additional services beyond those related to your store's wine recommendations such as discounts, quantity, rewards programs, promotions, delivery options, shipping, boxes, gift wrapping, packaging, personalized messages or something similar. These are the job of our sales team at the store.
# you should then respond to the user with interleaving plan, action_name, action_input in JSON format # you should then respond to the user with interleaving think, action_name, action_input in JSON format
1) "plan", Based on the current situation, state a complete action plan to complete the task and rationale. Be specific. 1) "think", Your step-by-step reasoning process. Explain why you are choosing this action.
2) "action_name", (Typically corresponds to the execution of the first step in your plan) Can be one of the available_actions name 2) "action_name", Can be one of the available actions
3) "action_input", The input to the action you are about to perform according to your plan. 3) "action_input", The input to the action you are about to perform.
After the action is executed you gets "action_result". It is the output from the action you selected. After the action is executed you gets "action_result". It is the output from the action you selected.
# available actions # available actions