update
This commit is contained in:
@@ -79,7 +79,7 @@ julia> output_thoughtDict = Dict(
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2<:AbstractDict}
|
||||
function decisionMaker(config::T1, state::T2)::Dict{Symbol, Any} where {T1<:AbstractDict, T2<:AbstractDict}
|
||||
customerinfo =
|
||||
"""
|
||||
I will give you the following information about customer:
|
||||
@@ -169,7 +169,7 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
|
||||
"""
|
||||
|
||||
# apply LLM specific instruct format
|
||||
externalService = a.config[:externalservice][:text2textinstruct]
|
||||
externalService = config[:externalservice][:text2textinstruct]
|
||||
llminfo = externalService[:llminfo]
|
||||
prompt =
|
||||
if llminfo[:name] == "llama3instruct"
|
||||
@@ -181,10 +181,10 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
|
||||
msgMeta = GeneralUtils.generate_msgMeta(
|
||||
externalService[:mqtttopic],
|
||||
senderName= "decisionMaker",
|
||||
senderId= a.id,
|
||||
senderId= string(uuid4()),
|
||||
receiverName= "text2textinstruct",
|
||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
||||
mqttBroker= config[:mqttServerInfo][:broker],
|
||||
mqttBrokerPort= config[:mqttServerInfo][:port],
|
||||
)
|
||||
|
||||
outgoingMsg = Dict(
|
||||
@@ -212,7 +212,7 @@ function decisionMaker(a::T1, state::T2)::Dict{Symbol, Any} where {T1<:agent, T2
|
||||
"observation": "..."
|
||||
}
|
||||
"""
|
||||
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
|
||||
responseJsonStr = jsoncorrection(config, _responseJsonStr, expectedJsonExample)
|
||||
thoughtDict = copy(JSON3.read(responseJsonStr))
|
||||
|
||||
# check if dict has all required value
|
||||
@@ -786,6 +786,11 @@ function reflector(a::T1, state::T2)::String where {T1<:agent, T2<:AbstractDict}
|
||||
end
|
||||
|
||||
|
||||
function transition()
|
||||
error("--> transition")
|
||||
end
|
||||
|
||||
|
||||
# """ Determine whether the state is a terminal state
|
||||
|
||||
# # Arguments
|
||||
@@ -882,6 +887,7 @@ julia> response = ChatAgent.conversation(newAgent, "Hi! how are you?")
|
||||
# Signature
|
||||
"""
|
||||
function conversation(a::T, userinput::Dict) where {T<:agent}
|
||||
config = deepcopy(a.config)
|
||||
if userinput[:text] == "newtopic"
|
||||
clearhistory(a)
|
||||
return "Okay. What shall we talk about?"
|
||||
@@ -920,8 +926,9 @@ function conversation(a::T, userinput::Dict) where {T<:agent}
|
||||
end
|
||||
|
||||
while true
|
||||
bestNextState, besttrajectory = runMCTS(a, a.plan[:currenttrajectory], decisionMaker,
|
||||
evaluator, reflector, totalsample=2, maxDepth=3, maxiterations=3, explorationweight=1.0)
|
||||
bestNextState, besttrajectory = LLMMCTS.runMCTS(config, a.plan[:currenttrajectory],
|
||||
decisionMaker, evaluator, reflector, transition;
|
||||
totalsample=2, maxDepth=3, maxiterations=3, explorationweight=1.0)
|
||||
a.plan[:activeplan] = bestNextState
|
||||
|
||||
latestActionKey, latestActionIndice =
|
||||
|
||||
@@ -728,9 +728,9 @@ julia>
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function jsoncorrection(a::T1, input::T2, correctJsonExample::T3;
|
||||
function jsoncorrection(config::T1, input::T2, correctJsonExample::T3;
|
||||
maxattempt::Integer=3
|
||||
) where {T1<:agent, T2<:AbstractString, T3<:AbstractString}
|
||||
) where {T1<:AbstractDict, T2<:AbstractString, T3<:AbstractString}
|
||||
|
||||
incorrectjson = deepcopy(input)
|
||||
correctjson = nothing
|
||||
@@ -762,7 +762,7 @@ function jsoncorrection(a::T1, input::T2, correctJsonExample::T3;
|
||||
"""
|
||||
|
||||
# apply LLM specific instruct format
|
||||
externalService = a.config[:externalservice][:text2textinstruct]
|
||||
externalService = config[:externalservice][:text2textinstruct]
|
||||
llminfo = externalService[:llminfo]
|
||||
prompt =
|
||||
if llminfo[:name] == "llama3instruct"
|
||||
@@ -775,10 +775,10 @@ function jsoncorrection(a::T1, input::T2, correctJsonExample::T3;
|
||||
msgMeta = GeneralUtils.generate_msgMeta(
|
||||
externalService[:mqtttopic],
|
||||
senderName= "jsoncorrection",
|
||||
senderId= a.id,
|
||||
senderId= string(uuid4()),
|
||||
receiverName= "text2textinstruct",
|
||||
mqttBroker= a.config[:mqttServerInfo][:broker],
|
||||
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
||||
mqttBroker= config[:mqttServerInfo][:broker],
|
||||
mqttBrokerPort= config[:mqttServerInfo][:port],
|
||||
)
|
||||
|
||||
outgoingMsg = Dict(
|
||||
|
||||
Reference in New Issue
Block a user