update
This commit is contained in:
@@ -47,13 +47,13 @@ end
|
||||
""" Think and choose action
|
||||
|
||||
# Arguments
|
||||
`a::T1`
|
||||
- `a::T1`
|
||||
one of Yiem's agent
|
||||
`state::T2`
|
||||
- `state::T2`
|
||||
a game state
|
||||
|
||||
# Return
|
||||
`thought::Dict`
|
||||
- `thought::Dict`
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
@@ -145,7 +145,7 @@ function decisionMaker(a::T1, state::T2)::String where {T1<:agent, T2<:AbstractD
|
||||
prompt = formatLLMtext_llama3instruct("system", _prompt)
|
||||
|
||||
msgMeta = GeneralUtils.generate_msgMeta(
|
||||
a.config[:externalService][:text2textinstruct][:mqtttopic],
|
||||
a.config[:externalservice][:text2textinstruct][:mqtttopic],
|
||||
senderName= "decisionMaker",
|
||||
senderId= a.id,
|
||||
receiverName= "text2textinstruct",
|
||||
|
||||
@@ -21,17 +21,90 @@ julia>
|
||||
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [WORKING] implement the function
|
||||
- [PENDING] implement the function
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function chatbox(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
||||
error("--> chatbox")
|
||||
|
||||
# put in model format
|
||||
if a.config[:externalService][]
|
||||
GeneralUtils.formatLLMtext_llama3instruct
|
||||
virtualWineCustomer = a.config[:externalservice][:virtualWineCustomer_1]
|
||||
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
|
||||
|
||||
|
||||
|
||||
""" 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.
|
||||
|
||||
Arguments\n
|
||||
|
||||
@@ -136,7 +136,7 @@ function expand(a::T1, node::MCTSNode, state::T2, decisionMaker::Function, state
|
||||
action = _action[:action]
|
||||
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)
|
||||
node.children[newState] = MCTSNode(newState, 0, 0.0, Dict{T, MCTSNode}())
|
||||
@@ -230,14 +230,14 @@ julia>
|
||||
|
||||
# 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}
|
||||
|
||||
|
||||
# map action and input() to llm function
|
||||
result =
|
||||
if action == "chatbox"
|
||||
chatbox(a, input)
|
||||
virtualWineCustomerChatbox(a, input) # user virtu
|
||||
elseif action == "winestock"
|
||||
|
||||
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
|
||||
:internal=> instanceInternalTopic,
|
||||
),
|
||||
:externalService=> config[:externalService],
|
||||
:externalservice=> config[:externalservice],
|
||||
)
|
||||
|
||||
# Instantiate an agent
|
||||
|
||||
Reference in New Issue
Block a user