use JSON instead
This commit is contained in:
+14
-14
@@ -3,7 +3,7 @@ module interface
|
||||
export addNewMessage, conversation, decisionMaker, reflector, generatechat,
|
||||
generalconversation, detectWineryName, generateSituationReport
|
||||
|
||||
using JSON3, DataStructures, Dates, UUIDs, HTTP, Random, PrettyPrinting, Serialization,
|
||||
using JSON, DataStructures, Dates, UUIDs, HTTP, Random, PrettyPrinting, Serialization,
|
||||
DataFrames, CSV
|
||||
using GeneralUtils
|
||||
using ..type, ..util, ..llmfunction
|
||||
@@ -100,7 +100,7 @@ julia> output_thoughtDict = Dict(
|
||||
function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
) where {T<:agent}
|
||||
println("\nExecuting YiemAgent decisionMaker()")
|
||||
# lessonDict = copy(JSON3.read("lesson.json"))
|
||||
# lessonDict = copy(JSON.parsefile("lesson.json"))
|
||||
|
||||
# lesson =
|
||||
# if isempty(lessonDict)
|
||||
@@ -118,7 +118,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
# did previously. Use them to improve your strategy to help the user.
|
||||
|
||||
# Here are some lessons in JSON format:
|
||||
# $(JSON3.write(lessons))
|
||||
# $(JSON.json(lessons))
|
||||
|
||||
# When providing the thought and action for the current trial, that into account these failed
|
||||
# trajectories and make sure not to repeat the same mistakes and incorrect answers.
|
||||
@@ -293,7 +293,7 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
response = strip(response)
|
||||
responsedict = nothing
|
||||
try
|
||||
responsedict = copy(JSON3.read(response))
|
||||
responsedict = copy(JSON.parsefile(response))
|
||||
catch
|
||||
println("\nERROR YiemAgent decisionMaker() failed to parse response: $response", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
@@ -399,15 +399,15 @@ function decisionMaker(a::T; recentevents::Integer=20, maxattempt=10
|
||||
# decisionlist = [responsedict]
|
||||
# println("Creating file $filepath")
|
||||
# open(filepath, "w") do io
|
||||
# JSON3.pretty(io, decisionlist)
|
||||
# JSON.pretty(io, decisionlist)
|
||||
# end
|
||||
# else
|
||||
# # read the file and append new data
|
||||
# decisionlist = copy(JSON3.read(filepath))
|
||||
# decisionlist = copy(JSON.parsefile(filepath))
|
||||
# push!(decisionlist, responsedict)
|
||||
# println("Appending new data to file $filepath")
|
||||
# open(filepath, "w") do io
|
||||
# JSON3.pretty(io, decisionlist)
|
||||
# JSON.pretty(io, decisionlist)
|
||||
# end
|
||||
# end
|
||||
# println("\nYiemAgent decisionMaker() saved to disk is done. agent $(a.id)")
|
||||
@@ -536,7 +536,7 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
||||
|
||||
responsedict = nothing
|
||||
try
|
||||
responsedict = copy(JSON3.read(response))
|
||||
responsedict = copy(JSON.parsefile(response))
|
||||
catch
|
||||
println("\nERROR YiemAgent generatechat() failed to parse response: $response", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
@@ -568,15 +568,15 @@ function evaluator(a::T1, timeline, decisiondict, evaluateecontext
|
||||
# decisionlist = [responsedict]
|
||||
# println("Creating file $filepath")
|
||||
# open(filepath, "w") do io
|
||||
# JSON3.pretty(io, decisionlist)
|
||||
# JSON.pretty(io, decisionlist)
|
||||
# end
|
||||
# else
|
||||
# # read the file and append new data
|
||||
# decisionlist = copy(JSON3.read(filepath))
|
||||
# decisionlist = copy(JSON.parsefile(filepath))
|
||||
# push!(decisionlist, responsedict)
|
||||
# println("Appending new data to file $filepath")
|
||||
# open(filepath, "w") do io
|
||||
# JSON3.pretty(io, decisionlist)
|
||||
# JSON.pretty(io, decisionlist)
|
||||
# end
|
||||
# end
|
||||
|
||||
@@ -597,7 +597,7 @@ end
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> using JSON3, UUIDs, Dates, FileIO, MQTTClient, ChatAgent
|
||||
julia> using JSON, UUIDs, Dates, FileIO, MQTTClient, ChatAgent
|
||||
julia> const mqttBroker = "mqtt.yiem.cc"
|
||||
julia> mqttclient, connection = MakeConnection(mqttBroker, 1883)
|
||||
julia> tools=Dict( # update input format
|
||||
@@ -966,7 +966,7 @@ function presentbox(a::sommelier, thoughtDict; maxtattempt::Integer=10, recentev
|
||||
|
||||
responsedict = nothing
|
||||
try
|
||||
responsedict = copy(JSON3.read(response))
|
||||
responsedict = copy(JSON.parsefile(response))
|
||||
catch
|
||||
println("\nERROR YiemAgent presentbox() failed to parse response: $response ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
@@ -1141,7 +1141,7 @@ function generatechat(a::sommelier, thoughtDict; maxattempt::Integer=10)
|
||||
|
||||
responsedict = nothing
|
||||
try
|
||||
responsedict = copy(JSON3.read(response))
|
||||
responsedict = copy(JSON.parsefile(response))
|
||||
catch
|
||||
println("\nERROR YiemAgent generatechat() failed to parse response: $response", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user