update
This commit is contained in:
@@ -89,8 +89,22 @@ function transition(state::T1, args::NamedTuple
|
||||
# only for the 1st transition
|
||||
if state[:errormsg] === nothing
|
||||
response, errormsg, reward, isterminal = executeJSON(state[:question])
|
||||
state[:response] = response
|
||||
state[:errormsg] = errormsg
|
||||
if isterminal == true # question already correct
|
||||
# make new state
|
||||
newNodeKey = GeneralUtils.uuid4snakecase()
|
||||
newstate = deepcopy(state)
|
||||
newstate[:code] = state[:question]
|
||||
newstate[:response] = response
|
||||
newstate[:errormsg] = errormsg
|
||||
newstate[:errorexplain] = "already correct JSON"
|
||||
newstate[:reward] = reward
|
||||
newstate[:isterminal] = isterminal
|
||||
|
||||
return (newNodeKey=newNodeKey, newstate=newstate, progressvalue=10)
|
||||
else # prep for entering correction loop so that decisionMaker has errormsg to work with
|
||||
state[:response] = response
|
||||
state[:errormsg] = errormsg
|
||||
end
|
||||
end
|
||||
|
||||
explain, jsonstr = decisionMaker(state, config, context)
|
||||
@@ -215,9 +229,17 @@ function decisionMaker(state, config, context)
|
||||
_responseJsonStr = response[:response][:text]
|
||||
|
||||
if length(split(_responseJsonStr, "Code:")) == 2
|
||||
return split(_responseJsonStr, "Code:")
|
||||
x = split(_responseJsonStr, "Code:")
|
||||
if occursin("Why", x[2])
|
||||
error("88")
|
||||
end
|
||||
return x
|
||||
elseif length(split(_responseJsonStr, "Code\":")) == 2
|
||||
return split(_responseJsonStr, "Code\":")
|
||||
x = split(_responseJsonStr, "Code\":")
|
||||
if occursin("Why", x[2])
|
||||
error("88")
|
||||
end
|
||||
return x
|
||||
else
|
||||
println("Trying to get Code part")
|
||||
end
|
||||
@@ -316,9 +338,6 @@ function executeJSON(jsonstring)
|
||||
showerror(io, e)
|
||||
errorMsg = String(take!(io))
|
||||
st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace()))
|
||||
println("")
|
||||
|
||||
println("")
|
||||
return (response=nothing, errormsg=errorMsg, reward=0, isterminal=false)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user