update
This commit is contained in:
@@ -214,7 +214,7 @@ deps = ["Random"]
|
|||||||
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
|
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
|
||||||
|
|
||||||
[[deps.GeneralUtils]]
|
[[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"
|
path = "/appfolder/app/privatejuliapkg/GeneralUtils"
|
||||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ using LLMMCTS, GeneralUtils
|
|||||||
A number to limit how many attempt will be made.
|
A number to limit how many attempt will be made.
|
||||||
|
|
||||||
# Return
|
# 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.
|
if success=`true`, response is a valid JSON string. otherwise, check errormsg.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
@@ -91,8 +91,8 @@ julia> println(result)
|
|||||||
|
|
||||||
# Signature
|
# Signature
|
||||||
"""
|
"""
|
||||||
function jsoncorrection(jsonstring::T, example::String, commfunction::Function;
|
function jsoncorrection(jsonstring::T, example::String, commfunction::Function; maxattempt=3
|
||||||
maxattempt=3)::NamedTuple where {T<:AbstractString}
|
)::@NamedTuple{response::String, errormsg::String, success::Bool} where {T<:AbstractString}
|
||||||
|
|
||||||
initialstate = Dict{Symbol, Any}(
|
initialstate = Dict{Symbol, Any}(
|
||||||
:reward=> 0,
|
:reward=> 0,
|
||||||
@@ -116,9 +116,9 @@ function jsoncorrection(jsonstring::T, example::String, commfunction::Function;
|
|||||||
totalsample=1, maxdepth=(maxattempt-1), maxiterations=1, explorationweight=1.0)
|
totalsample=1, maxdepth=(maxattempt-1), maxiterations=1, explorationweight=1.0)
|
||||||
|
|
||||||
if result[:isterminal] == true
|
if result[:isterminal] == true
|
||||||
return (response=result[:code], errormsg=nothing, success=true)
|
return (response=result[:code], errormsg="nothing", success=true)
|
||||||
else
|
else
|
||||||
return (response=nothing, errormsg=result[:errorexplain], success=false)
|
return (response="nothing", errormsg=result[:errorexplain], success=false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user