This commit is contained in:
narawat lamaiin
2024-07-10 11:43:00 +07:00
parent 695cd6a2b9
commit 1a5fd9afa3
2 changed files with 6 additions and 6 deletions

View File

@@ -214,7 +214,7 @@ deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
[[deps.GeneralUtils]]
deps = ["DataStructures", "Dates", "Distributions", "JSON3", "MQTTClient", "Random", "Revise", "UUIDs"]
deps = ["CSV", "DataFrames", "DataStructures", "Dates", "Distributions", "JSON3", "MQTTClient", "Random", "Revise", "UUIDs"]
path = "/appfolder/app/privatejuliapkg/GeneralUtils"
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
version = "0.1.0"

View File

@@ -23,7 +23,7 @@ using LLMMCTS, GeneralUtils
A number to limit how many attempt will be made.
# Return
- `(response, errormsg, success)::NamedTuple`
- `(response, errormsg, success)::@NamedTuple{response::String, errormsg::String, success::Bool}`
if success=`true`, response is a valid JSON string. otherwise, check errormsg.
# Example
@@ -91,8 +91,8 @@ julia> println(result)
# Signature
"""
function jsoncorrection(jsonstring::T, example::String, commfunction::Function;
maxattempt=3)::NamedTuple where {T<:AbstractString}
function jsoncorrection(jsonstring::T, example::String, commfunction::Function; maxattempt=3
)::@NamedTuple{response::String, errormsg::String, success::Bool} where {T<:AbstractString}
initialstate = Dict{Symbol, Any}(
:reward=> 0,
@@ -116,9 +116,9 @@ function jsoncorrection(jsonstring::T, example::String, commfunction::Function;
totalsample=1, maxdepth=(maxattempt-1), maxiterations=1, explorationweight=1.0)
if result[:isterminal] == true
return (response=result[:code], errormsg=nothing, success=true)
return (response=result[:code], errormsg="nothing", success=true)
else
return (response=nothing, errormsg=result[:errorexplain], success=false)
return (response="nothing", errormsg=result[:errorexplain], success=false)
end
end