update
This commit is contained in:
@@ -87,15 +87,14 @@ using ..type, ..util, ..llmfunction
|
|||||||
""" #TODO update document
|
""" #TODO update document
|
||||||
function conversation(a::T) where {T<:agent}
|
function conversation(a::T) where {T<:agent}
|
||||||
while true
|
while true
|
||||||
println("---> conversation loop")
|
|
||||||
println("---> a.receiveUserMsgChannel ready = $(isready(a.receiveUserMsgChannel))")
|
|
||||||
# check for incoming user message
|
# check for incoming user message
|
||||||
if isready(a.receiveUserMsgChannel)
|
if isready(a.receiveUserMsgChannel)
|
||||||
incomingMsg = take!(a.receiveUserMsgChannel)
|
incomingMsg = take!(a.receiveUserMsgChannel)
|
||||||
incomingPayload = incomingMsg[:payload]
|
incomingPayload = incomingMsg[:payload]
|
||||||
|
|
||||||
|
# "newtopic" command to delete chat history
|
||||||
if incomingPayload[:text] == "newtopic"
|
if incomingPayload[:text] == "newtopic"
|
||||||
clearhistory(a)
|
clearhistory(a)
|
||||||
@show incomingMsg
|
|
||||||
msgMeta = deepcopy(a.msgMeta)
|
msgMeta = deepcopy(a.msgMeta)
|
||||||
msgMeta[:sendTopic] = incomingMsg[:msgMeta][:replyTopic]
|
msgMeta[:sendTopic] = incomingMsg[:msgMeta][:replyTopic]
|
||||||
msgMeta[:senderName] = "agent-backend"
|
msgMeta[:senderName] = "agent-backend"
|
||||||
@@ -116,22 +115,16 @@ function conversation(a::T) where {T<:agent}
|
|||||||
client, connection = MakeConnection(a.config[:mqttinfo][:broker],
|
client, connection = MakeConnection(a.config[:mqttinfo][:broker],
|
||||||
a.config[:mqttinfo][:port])
|
a.config[:mqttinfo][:port])
|
||||||
connect(client, connection)
|
connect(client, connection)
|
||||||
|
|
||||||
@show outgoingMsg
|
|
||||||
publish(client, outgoingMsg[:msgMeta][:sendTopic],
|
publish(client, outgoingMsg[:msgMeta][:sendTopic],
|
||||||
JSON3.write(outgoingMsg))
|
JSON3.write(outgoingMsg))
|
||||||
disconnect(client)
|
disconnect(client)
|
||||||
println("published")
|
|
||||||
else
|
else # a new thinking
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# # if new message == "newtopic"
|
|
||||||
# #TODO add "newtopic" command to delete history
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # else
|
# # else
|
||||||
@@ -149,7 +142,7 @@ function conversation(a::T) where {T<:agent}
|
|||||||
# # actor loop(best plan)
|
# # actor loop(best plan)
|
||||||
|
|
||||||
# # end
|
# # end
|
||||||
sleep(3)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user