update
This commit is contained in:
108
src/interface.jl
108
src/interface.jl
@@ -85,59 +85,83 @@ using ..type, ..util, ..llmfunction
|
||||
Signature\n
|
||||
-----
|
||||
""" #TODO update document
|
||||
function conversation(a::T, usermsg::String) where {T<:agent}
|
||||
#TODO add "newtopic" command to delete history
|
||||
|
||||
# add usermsg to a.chathistory
|
||||
addNewMessage(a, "user", usermsg)
|
||||
function conversation(a::T) where {T<:agent}
|
||||
while true
|
||||
println("---> conversation loop")
|
||||
println("---> a.receiveUserMsgChannel ready = $(isready(a.receiveUserMsgChannel))")
|
||||
#TODO add "newtopic" command to delete history
|
||||
# check for incoming user message
|
||||
if isready(a.receiveUserMsgChannel)
|
||||
incomingMsg = take!(a.receiveUserMsgChannel)
|
||||
@show incomingMsg
|
||||
end
|
||||
|
||||
|
||||
# # if new user message available
|
||||
|
||||
# # if new message == "newtopic"
|
||||
# #TODO add "newtopic" command to delete history
|
||||
|
||||
#WORKING if the last used tool is a chatbox
|
||||
if a.plan[:currenttrajectory][end][:action] == "chatbox"
|
||||
# usermsg -> observation and continue actor loop as planned
|
||||
|
||||
|
||||
else # a new thinking
|
||||
|
||||
end
|
||||
# # else
|
||||
# # add usermsg to a.chathistory
|
||||
# addNewMessage(a, "user", usermsg)
|
||||
|
||||
# #WORKING if the last used tool is a chatbox
|
||||
# # if a.plan[:currenttrajectory][end][:action] == "chatbox"
|
||||
# # usermsg -> observation and continue actor loop as planned
|
||||
|
||||
|
||||
# # else # a new thinking
|
||||
# # planning with MCTS() -> best plan
|
||||
|
||||
# # actor loop(best plan)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
workstate = nothing
|
||||
response = nothing
|
||||
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
isuseplan = isUsePlans(a)
|
||||
# newinfo = extractinfo(a, usermsg)
|
||||
# a.env = newinfo !== nothing ? updateEnvState(a, newinfo) : a.env
|
||||
@show isuseplan
|
||||
|
||||
if isuseplan # use plan before responding
|
||||
if haskey(a.memory[:shortterm], "User:") == false #TODO should change role if user want to buy wine.
|
||||
a.memory[:shortterm]["User:"] = usermsg
|
||||
end
|
||||
workstate, response = work(a)
|
||||
end
|
||||
|
||||
# if LLM using askbox, use returning msg form askbox as conversation response
|
||||
if workstate == "askbox" || workstate == "formulatedUserResponse"
|
||||
#TODO paraphrase msg so that it is human friendlier word.
|
||||
else
|
||||
response = chat_mistral_openorca(a)
|
||||
response = split(response, "\n\n")[1]
|
||||
response = split(response, "\n\n")[1]
|
||||
# # end
|
||||
sleep(3)
|
||||
end
|
||||
|
||||
response = removeTrailingCharacters(response)
|
||||
_ = addNewMessage(a, "assistant", response)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# workstate = nothing
|
||||
# response = nothing
|
||||
|
||||
# _ = addNewMessage(a, "user", usermsg)
|
||||
# isuseplan = isUsePlans(a)
|
||||
# # newinfo = extractinfo(a, usermsg)
|
||||
# # a.env = newinfo !== nothing ? updateEnvState(a, newinfo) : a.env
|
||||
# @show isuseplan
|
||||
|
||||
# if isuseplan # use plan before responding
|
||||
# if haskey(a.memory[:shortterm], "User:") == false #TODO should change role if user want to buy wine.
|
||||
# a.memory[:shortterm]["User:"] = usermsg
|
||||
# end
|
||||
# workstate, response = work(a)
|
||||
# end
|
||||
|
||||
# # if LLM using askbox, use returning msg form askbox as conversation response
|
||||
# if workstate == "askbox" || workstate == "formulatedUserResponse"
|
||||
# #TODO paraphrase msg so that it is human friendlier word.
|
||||
# else
|
||||
# response = chat_mistral_openorca(a)
|
||||
# response = split(response, "\n\n")[1]
|
||||
# response = split(response, "\n\n")[1]
|
||||
# end
|
||||
|
||||
# response = removeTrailingCharacters(response)
|
||||
# _ = addNewMessage(a, "assistant", response)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user