This commit is contained in:
narawat lamaiin
2024-07-07 20:59:12 +07:00
parent 0a7c2e15bf
commit d715b0c22d
2 changed files with 38 additions and 12 deletions

View File

@@ -8,24 +8,50 @@ using LLMMCTS, GeneralUtils
# ---------------------------------------------- 100 --------------------------------------------- #
"""
""" Attempt to correct JSON string.
# Arguments
- `config::Dict`
A config containing services and mqttbroker info
# Return
# Example
```jldoctest
julia>
julia> config = Dict(
:mqttServerInfo => Dict(
:description => "mqtt server info",
:port => 1883,
:broker => "mqtt.yiem.cc"
),
:externalservice => Dict(
:text2textinstruct => Dict(
:mqtttopic => "/loadbalancer/requestingservice",
:description => "text to text service with instruct LLM",
:llminfo => Dict(:name => "llama3instruct")
),
)
)
julia> expectJSON =
"
Here is an expected JSON format:
{
explain: ...,
plan: ...,
action: {name: ..., input: ...},
expectation: ...,
observation: ...
}
"
```
# TODO
- [] update docstring
- [] implement the function
- [x] implement the function
# Signature
"""
function jsoncorrection(config::Dict, jsonstring::String, context; maxattempt=3)
function jsoncorrection(config::Dict, jsonstring::String, example; maxattempt=3)
initialstate = Dict{Symbol, Any}(
:reward=> 0,
@@ -41,7 +67,7 @@ function jsoncorrection(config::Dict, jsonstring::String, context; maxattempt=3)
transitionargs = (
config=config,
context=context,
context=example,
)
_, result = LLMMCTS.runMCTS(initialstate, transition, transitionargs;
totalsample=1, maxdepth=(maxattempt-1), maxiterations=1, explorationweight=1.0)