v0.7.4-add_vector_search #32

Merged
ton merged 11 commits from v0.7.4-add_vector_search into main 2026-07-26 15:21:54 +00:00
3 changed files with 105 additions and 28 deletions
Showing only changes of commit d7adfaffa8 - Show all commits
+83 -21
View File
@@ -122,10 +122,70 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
errornote = "N/A"
response = nothing # placeholder for show when error msg show up
"""
{
"model": "your-model.gguf",
"messages": [ ... ],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "agent_action",
"strict": true,
"schema": {
"type": "object",
"properties": {
"think": {
"type": "string",
"description": "Your step-by-step reasoning process. Explain why you are choosing this action."
},
"action_name": {
"type": "string",
"enum": ["search_web", "get_weather", "calculate_math"],
"description": "The exact name of the tool to execute."
},
"action_input": {
"type": "object",
"properties": {
"query": { "type": ["string", "null"], "description": "For search_web" },
"location": { "type": ["string", "null"], "description": "For get_weather" },
"equation": { "type": ["string", "null"], "description": "For calculate_math" }
},
"required": ["query", "location", "equation"],
"additionalProperties": false
}
},
"required": ["think", "action_name", "action_input"],
"additionalProperties": false
}
}
}
}
"""
# strict output format
json_schema = Dict(
"type"=> "json_schema",
"json_schema"=> Dict(
"name"=> "user_profile",
"strict"=> true,
"schema"=> Dict(
"type"=> "object",
"properties"=> Dict(
"plan"=> Dict("type"=> "string"),
"action_name"=> Dict("type"=> "string"),
"action_input"=> Dict("type"=> "string"),
),
"required"=> ["plan", "action_name", "action_input"],
"additionalProperties"=> false
)
)
)
msg = Dict(
"model" => "gemma-4-E4B-it-UD-Q4_K_XL",
"messages" => a.chathistory,
"temperature" => 0.7
"model"=> "gemma-4-E4B-it-UD-Q4_K_XL",
"messages"=> a.chathistory,
"temperature"=> 0.7,
"response_format"=> json_schema,
)
for attempt in 1:maxattempt
@@ -138,25 +198,27 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=3
response = replace(response, '$' => "USD")
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
# 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)
# # 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
# if !ispass
# errornote = errormsg
# println("\nERROR YiemAgent decisionMaker() $errornote --(not qualify response)-> $responsedict ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
# continue
# end
responsedict = JSON.parse(response)
if responsedict["action_input"] == "CHAT_BOX" &&
occursin("similar", responsedict["action_input"])
@@ -564,7 +626,7 @@ function think(a::T)::NamedTuple{(:thoughtdict, :result_raw), Tuple{OrderedDict,
end
@info "YiemAgent think() end " @__LINE__
@show thoughtdict
# @show thoughtdict
println("---\n")
return (thoughtdict=thoughtdict, result_raw=result_raw)
end
+21 -1
View File
@@ -637,7 +637,8 @@ function predefined_wine_search_sql(a::T, searchterm::String,
# your responsibility includes
Fulfill the objective.
# you should only respond in YAML format as described below
# you should only respond in JSON format as described below
{
table_name_1:
column_name_1:
operator: "="
@@ -654,6 +655,7 @@ function predefined_wine_search_sql(a::T, searchterm::String,
operator: "="
value: "..."
...
}
# here are some example
<user>
@@ -700,6 +702,24 @@ function predefined_wine_search_sql(a::T, searchterm::String,
"""
input = context * searchterm
json_schema = Dict(
"type"=> "json_schema",
"json_schema"=> Dict(
"name"=> "user_profile",
"strict"=> true,
"schema"=> Dict(
"type"=> "object",
"properties"=> Dict(
"plan"=> Dict("type"=> "string"),
"action_name"=> Dict("type"=> "string"),
"action_input"=> Dict("type"=> "string"),
),
"required"=> ["plan", "action_name", "action_input"],
"additionalProperties"=> false
)
)
)
msg = Dict(
"model" => "gemma-4-E4B-it-UD-Q4_K_XL",
"messages" => [
+1 -6
View File
@@ -200,17 +200,12 @@ function sommelier(
- 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.
# you should then respond to the user with interleaving plan, action_name, action_input
# you should then respond to the user with interleaving plan, 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.
2) "action_name", (Typically corresponds to the execution of the first step in your plan) Can be one of the available_actions name
3) "action_input", The input to the action you are about to perform according to your plan.
After the action is executed you gets "action_result". It is the output from the action you selected.
# you should only respond in YAML format as described below
plan: "..."
action_name: "..."
action_input: "..."
# available actions
"CHAT_BOX", which you can use to talk with the user. The input is dialogue you want to chat with the user according to your plan.
"SEARCH_WINE_DATABASE", allows you to search information about wines you want in your inventory's database. The input is strictly supported search term including: retailer_name, wine price, winery, name, vintage, region, country, type of wine, grape varietal, tasting notes, occasion, food pairing, intensity, tannin, sweetness, and acidity.