update
This commit is contained in:
@@ -381,7 +381,7 @@ julia>
|
||||
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [TESTING] implement the function
|
||||
- [x] implement the function
|
||||
|
||||
# Signature
|
||||
"""
|
||||
|
||||
26
src/mcts.jl
26
src/mcts.jl
@@ -7,7 +7,7 @@ module mcts
|
||||
|
||||
export MCTSNode, runMCTS, isleaf
|
||||
|
||||
using Dates, UUIDs, DataStructures, JSON3, Random
|
||||
using Dates, UUIDs, DataStructures, JSON3, Random, PrettyPrinting
|
||||
using GeneralUtils
|
||||
using ..type, ..llmfunction
|
||||
|
||||
@@ -211,13 +211,11 @@ end
|
||||
current game state
|
||||
- `thoughtDict::T3`
|
||||
contain Thought, Action, Observation
|
||||
- `isterminal::Function`
|
||||
a function to determine terminal state
|
||||
|
||||
# Return
|
||||
- (newNodeKey, )
|
||||
- `newNodeKey::String`
|
||||
key for newstate
|
||||
- `newstate::Dict{Symbol, Any}`
|
||||
next game state
|
||||
- `(newNodeKey, newstate, isterminalstate, reward)::Tuple{String, Dict{Symbol, <:Any}, Bool, <:Number}`
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
@@ -238,16 +236,14 @@ julia> thoughtDict = Dict(
|
||||
```
|
||||
|
||||
# TODO
|
||||
- [WORKING] update docstring
|
||||
- [PENDING] add other actions
|
||||
- [] add embedding of newstate and store in newstate[:embedding]
|
||||
- [x] check for terminal state and assign reward
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function MCTStransition(a::T1, state::T2, thoughtDict::T3, isterminal::Function
|
||||
)::Tuple{String, Dict{Symbol, <:Any}, Bool, <:Number} where {T1<:agent, T2<:AbstractDict, T3<:AbstractDict}
|
||||
|
||||
pprint(thoughtDict)
|
||||
actionname = thoughtDict[:Action][:name]
|
||||
actioninput = thoughtDict[:Action][:input]
|
||||
|
||||
@@ -279,7 +275,7 @@ function MCTStransition(a::T1, state::T2, thoughtDict::T3, isterminal::Function
|
||||
newNodeKey = GeneralUtils.uuid4snakecase()
|
||||
isterminalstate, reward = isterminal(newstate)
|
||||
|
||||
return newNodeKey, newstate, isterminalstate, reward
|
||||
return (newNodeKey, newstate, isterminalstate, reward)
|
||||
end
|
||||
|
||||
|
||||
@@ -317,21 +313,21 @@ isleaf(node::MCTSNode)::Bool = isempty(node.children)
|
||||
""" Select child node based on the highest progressValue
|
||||
|
||||
# Arguments
|
||||
- `node::MCTSNode`
|
||||
node of a search tree
|
||||
|
||||
# Return
|
||||
- `childNode::MCTSNode`
|
||||
the highest value child node
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
# TODO
|
||||
- [WORKING] update docstring
|
||||
- [x] implement the function
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function selectChildNode(node::MCTSNode)
|
||||
function selectChildNode(node::MCTSNode)::MCTSNode
|
||||
highestProgressValue = 0
|
||||
nodekey = nothing
|
||||
|
||||
|
||||
38
src/type.jl
38
src/type.jl
@@ -12,31 +12,28 @@ abstract type agent end
|
||||
|
||||
""" A sommelier agent.
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
mqttClient::Client
|
||||
# Arguments
|
||||
- `mqttClient::Client`
|
||||
MQTTClient's client
|
||||
msgMeta::Dict{Symbol, Any}
|
||||
- `msgMeta::Dict{Symbol, Any}`
|
||||
A dict contain info about a message.
|
||||
config::Dict{Symbol, Any}
|
||||
- `config::Dict{Symbol, Any}`
|
||||
Config info for an agent. Contain mqtt topic for internal use and other info.
|
||||
|
||||
Keyword Arguments\n
|
||||
-----
|
||||
name::String
|
||||
# Keyword Arguments
|
||||
- `name::String`
|
||||
Agent's name
|
||||
id::String
|
||||
- `id::String`
|
||||
Agent's ID
|
||||
tools::Dict{Symbol, Any}
|
||||
- `tools::Dict{Symbol, Any}`
|
||||
Agent's tools
|
||||
maxHistoryMsg::Integer
|
||||
- `maxHistoryMsg::Integer`
|
||||
max history message
|
||||
|
||||
Return\n
|
||||
-----
|
||||
nothing
|
||||
# Return
|
||||
- `nothing`
|
||||
|
||||
Example:
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> using YiemAgent, MQTTClient, GeneralUtils
|
||||
julia> msgMeta = GeneralUtils.generate_msgMeta(
|
||||
@@ -75,16 +72,15 @@ abstract type agent end
|
||||
```
|
||||
|
||||
# TODO
|
||||
- [WORKING] update docstring
|
||||
- [] update docstring
|
||||
- [x] implement the function
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
# Signature
|
||||
"""
|
||||
@kwdef mutable struct sommelier <: agent
|
||||
name::String
|
||||
id::String
|
||||
config::Dict
|
||||
name::String # agent name
|
||||
id::String # agent id
|
||||
config::Dict # agent config
|
||||
tools::Dict
|
||||
thinkinglimit::Integer # thinking round limit
|
||||
thinkingcount::Integer # used to count attempted round of a task
|
||||
|
||||
44
src/util.jl
44
src/util.jl
@@ -1,6 +1,6 @@
|
||||
module util
|
||||
|
||||
export clearhistory, addNewMessage, formatLLMtext, syntaxcheck_json, iterativeprompting,
|
||||
export clearhistory, addNewMessage, formatLLMtext, iterativeprompting,
|
||||
formatLLMtext_llama3instruct, formatLLMtext_phi3instruct
|
||||
|
||||
using UUIDs, Dates, DataStructures, HTTP, MQTTClient, JSON3
|
||||
@@ -269,48 +269,6 @@ function formatLLMtext(messages::Vector{Dict{Symbol, T}},
|
||||
end
|
||||
|
||||
|
||||
|
||||
""" Check JSON format correctness and provide feedback
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
jsonstring::T
|
||||
|
||||
Return\n
|
||||
-----
|
||||
(correct, critique)
|
||||
|
||||
Example\n
|
||||
-----
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
TODO\n
|
||||
-----
|
||||
[] update docstring
|
||||
[PENDING] implement the function
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
"""
|
||||
function syntaxcheck_json(jsonstring::T)::NamedTuple where {T<:AbstractString}
|
||||
error("--> syntaxcheck_json")
|
||||
success, result, errormsg, st = GeneralUtils.showstracktrace(JSON3.read, jsonstring)
|
||||
if !success # gives feedback
|
||||
|
||||
|
||||
|
||||
else
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
return (success, critique)
|
||||
end
|
||||
|
||||
|
||||
"""
|
||||
|
||||
Arguments\n
|
||||
|
||||
Reference in New Issue
Block a user