This commit is contained in:
narawat lamaiin
2024-07-10 17:32:14 +07:00
parent 1a5fd9afa3
commit 96aa221ee5

View File

@@ -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::String, errormsg::String, success::Bool}` - `NamedTuple{(:result, :errormsg, :success), Tuple{Union{String, Nothing}, Union{String, Nothing}, 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
@@ -92,7 +92,7 @@ julia> println(result)
# Signature # Signature
""" """
function jsoncorrection(jsonstring::T, example::String, commfunction::Function; maxattempt=3 function jsoncorrection(jsonstring::T, example::String, commfunction::Function; maxattempt=3
)::@NamedTuple{response::String, errormsg::String, success::Bool} where {T<:AbstractString} )::NamedTuple{(:result, :errormsg, :success), Tuple{Union{String, Nothing}, Union{String, Nothing}, 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 (result=result[:code], errormsg=nothing, success=true)
else else
return (response="nothing", errormsg=result[:errorexplain], success=false) return (result=nothing, errormsg=result[:errorexplain], success=false)
end end
end end