update
This commit is contained in:
@@ -47,13 +47,13 @@ end
|
|||||||
""" Think and choose action
|
""" Think and choose action
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
`a::T1`
|
- `a::T1`
|
||||||
one of Yiem's agent
|
one of Yiem's agent
|
||||||
`state::T2`
|
- `state::T2`
|
||||||
a game state
|
a game state
|
||||||
|
|
||||||
# Return
|
# Return
|
||||||
`thought::Dict`
|
- `thought::Dict`
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
```jldoctest
|
```jldoctest
|
||||||
@@ -145,7 +145,7 @@ function decisionMaker(a::T1, state::T2)::String where {T1<:agent, T2<:AbstractD
|
|||||||
prompt = formatLLMtext_llama3instruct("system", _prompt)
|
prompt = formatLLMtext_llama3instruct("system", _prompt)
|
||||||
|
|
||||||
msgMeta = GeneralUtils.generate_msgMeta(
|
msgMeta = GeneralUtils.generate_msgMeta(
|
||||||
a.config[:externalService][:text2textinstruct][:mqtttopic],
|
a.config[:externalservice][:text2textinstruct][:mqtttopic],
|
||||||
senderName= "decisionMaker",
|
senderName= "decisionMaker",
|
||||||
senderId= a.id,
|
senderId= a.id,
|
||||||
receiverName= "text2textinstruct",
|
receiverName= "text2textinstruct",
|
||||||
|
|||||||
@@ -21,17 +21,90 @@ julia>
|
|||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
- [] update docstring
|
- [] update docstring
|
||||||
- [WORKING] implement the function
|
- [PENDING] implement the function
|
||||||
|
|
||||||
# Signature
|
# Signature
|
||||||
"""
|
"""
|
||||||
function chatbox(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
function chatbox(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
||||||
error("--> chatbox")
|
error("--> chatbox")
|
||||||
|
|
||||||
# put in model format
|
# put in model format
|
||||||
if a.config[:externalService][]
|
virtualWineCustomer = a.config[:externalservice][:virtualWineCustomer_1]
|
||||||
GeneralUtils.formatLLMtext_llama3instruct
|
llminfo = virtualWineCustomer[:llminfo]
|
||||||
|
formattedinput =
|
||||||
|
if llminfo[:name] == "llama3instruct"
|
||||||
|
formatLLMtext_llama3instruct("assistant", input)
|
||||||
|
else
|
||||||
|
error("llm model name is not defied yet $(@__LINE__)")
|
||||||
|
end
|
||||||
|
|
||||||
|
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
||||||
|
|
||||||
|
|
||||||
|
# return response
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
""" Chatbox for chatting with virtual wine customer.
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
- `a::T1`
|
||||||
|
one of Yiem's agent
|
||||||
|
- `input::T2`
|
||||||
|
text to be send to virtual wine customer
|
||||||
|
|
||||||
|
# Return
|
||||||
|
- `response::String`
|
||||||
|
response of virtual wine customer
|
||||||
|
# Example
|
||||||
|
```jldoctest
|
||||||
|
julia>
|
||||||
|
```
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
- [x] update docstring
|
||||||
|
- [TESTING] implement the function
|
||||||
|
|
||||||
|
# Signature
|
||||||
|
"""
|
||||||
|
function virtualWineCustomerChatbox(a::T1, input::T2)::String where {T1<:agent, T2<:AbstractString}
|
||||||
|
|
||||||
|
# put in model format
|
||||||
|
virtualWineCustomer = a.config[:externalservice][:virtualWineCustomer_1]
|
||||||
|
llminfo = virtualWineCustomer[:llminfo]
|
||||||
|
prompt =
|
||||||
|
if llminfo[:name] == "llama3instruct"
|
||||||
|
formatLLMtext_llama3instruct("assistant", input)
|
||||||
|
else
|
||||||
|
error("llm model name is not defied yet $(@__LINE__)")
|
||||||
|
end
|
||||||
|
|
||||||
|
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
|
||||||
|
msgMeta = GeneralUtils.generate_msgMeta(
|
||||||
|
virtualWineCustomer[:mqtttopic],
|
||||||
|
senderName= "virtualWineCustomerChatbox",
|
||||||
|
senderId= a.id,
|
||||||
|
receiverName= "virtualWineCustomer",
|
||||||
|
mqttBroker= a.config[:mqttServerInfo][:broker],
|
||||||
|
mqttBrokerPort= a.config[:mqttServerInfo][:port],
|
||||||
|
)
|
||||||
|
|
||||||
|
outgoingMsg = Dict(
|
||||||
|
:msgMeta=> msgMeta,
|
||||||
|
:payload=> Dict(
|
||||||
|
:text=> prompt,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
result = GeneralUtils.sendReceiveMqttMsg(outgoingMsg)
|
||||||
|
response = result[:response][:text]
|
||||||
|
|
||||||
|
return response
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
""" Search wine in stock.
|
""" Search wine in stock.
|
||||||
|
|
||||||
Arguments\n
|
Arguments\n
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ function expand(a::T1, node::MCTSNode, state::T2, decisionMaker::Function, state
|
|||||||
action = _action[:action]
|
action = _action[:action]
|
||||||
actioninput = _action[:input]
|
actioninput = _action[:input]
|
||||||
|
|
||||||
newState = transition(a, node.state, action, actioninput) #[] Implement your transition function
|
newState = MCTStransition(a, node.state, action, actioninput) #[] Implement your transition function
|
||||||
|
|
||||||
if newState ∉ keys(node.children)
|
if newState ∉ keys(node.children)
|
||||||
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
|
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
|
||||||
@@ -230,14 +230,14 @@ julia>
|
|||||||
|
|
||||||
# Signature
|
# Signature
|
||||||
"""
|
"""
|
||||||
function transition(a::T1, state::T2, action::T3,
|
function MCTStransition(a::T1, state::T2, action::T3,
|
||||||
actioninput::T3) where {T1<:agent, T2<:AbstractDict, T3<:AbstractString}
|
actioninput::T3) where {T1<:agent, T2<:AbstractDict, T3<:AbstractString}
|
||||||
|
|
||||||
|
|
||||||
# map action and input() to llm function
|
# map action and input() to llm function
|
||||||
result =
|
result =
|
||||||
if action == "chatbox"
|
if action == "chatbox"
|
||||||
chatbox(a, input)
|
virtualWineCustomerChatbox(a, input) # user virtu
|
||||||
elseif action == "winestock"
|
elseif action == "winestock"
|
||||||
|
|
||||||
elseif action == "finish"
|
elseif action == "finish"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ agentConfig = Dict(
|
|||||||
:prompt=> config[:servicetopic][:mqtttopic], # topic to receive prompt i.e. frontend send msg to this topic
|
:prompt=> config[:servicetopic][:mqtttopic], # topic to receive prompt i.e. frontend send msg to this topic
|
||||||
:internal=> instanceInternalTopic,
|
:internal=> instanceInternalTopic,
|
||||||
),
|
),
|
||||||
:externalService=> config[:externalService],
|
:externalservice=> config[:externalservice],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Instantiate an agent
|
# Instantiate an agent
|
||||||
|
|||||||
Reference in New Issue
Block a user