use JSON instead

This commit is contained in:
2026-06-21 08:51:39 +07:00
parent b5a00bc694
commit 99b2fda461
11 changed files with 254 additions and 226 deletions

View File

@@ -8,8 +8,8 @@ using Base.Threads
# load config
config = JSON3.read("/appfolder/app/dev/YiemAgent/test/config.json")
# config = copy(JSON3.read("../mountvolume/config.json"))
config = JSON.parsefile("/appfolder/app/dev/YiemAgent/test/config.json")
# config = copy(JSON.parsefile("../mountvolume/config.json"))
function executeSQL(sql::T) where {T<:AbstractString}
@@ -179,7 +179,7 @@ function similarSommelierDecision(recentevents::T1; maxdistance::Integer=3
println("\n~~~ found similar decision. row id $rowid, distance $distance ", @__FILE__, " ", @__LINE__)
output_b64 = df[1, :function_output_base64] # pick the closest match
_output_str = String(base64decode(output_b64))
output = copy(JSON3.read(_output_str))
output = copy(JSON.parsefile(_output_str))
return output
else
println("\n~~~ similar decision not found, max distance $maxdistance ", @__FILE__, " ", @__LINE__)
@@ -199,7 +199,7 @@ function insertSommelierDecision(recentevents::T1, decision::T2; maxdistance::In
if row == 0 || distance > maxdistance # no close enough SQL stored in the database
recentevents_embedding = getEmbedding(recentevents)[1]
recentevents = replace(recentevents, "'" => "")
decision_json = JSON3.write(decision)
decision_json = JSON.json(decision)
decision_base64 = base64encode(decision_json)
decision = replace(decision_json, "'" => "")

View File

@@ -46,7 +46,7 @@ thoughtDict = OrderedDict(
:Observation_6=> "I don't like it. Do you have another option?",
)
_thoughtJsonStr = JSON3.write(thoughtDict)
_thoughtJsonStr = JSON.json(thoughtDict)
thoughtJsonStr = _thoughtJsonStr[1:end-1] # remove } at the end
# @show thoughtJsonStr
@@ -100,7 +100,7 @@ Here are some examples:
Let's begin!
$(JSON3.write(thoughtDict))
$(JSON.json(thoughtDict))
{Thought_$nextThoughtIndice
"""

View File

@@ -4,7 +4,7 @@ using Base.Threads
# ---------------------------------------------- 100 --------------------------------------------- #
config = copy(JSON3.read("config.json"))
config = copy(JSON.parsefile("config.json"))
instanceInternalTopic = config[:serviceInternalTopic][:mqtttopic] * "/1"