update
This commit is contained in:
@@ -48,6 +48,7 @@ julia> addNewMessage(agent1, "user", "Where should I go to buy snacks")
|
||||
```
|
||||
"""
|
||||
function addNewMessage(a::T1, name::String, content::T2) where {T1<:agent, T2<:AbstractString}
|
||||
|
||||
if name ∉ a.availableRole # guard against typo
|
||||
error("name is not in agent.availableRole $(@__LINE__)")
|
||||
end
|
||||
@@ -181,18 +182,14 @@ function chat_mistral_openorca(a::agentReflex, prompttemplate="llama3")
|
||||
{longterm memory}
|
||||
"
|
||||
"""
|
||||
|
||||
conversation = formatLLMtext(a.messages, "llama3instruct")
|
||||
|
||||
prompt =
|
||||
"""
|
||||
$conversation
|
||||
"""
|
||||
|
||||
response = sendReceivePrompt(a, prompt, a.config[:text2textchat][:mqtttopic],
|
||||
_response = sendReceivePrompt(a, prompt, a.config[:text2textchat][:mqtttopic],
|
||||
timeout=180, stopword=["<|", "</"])
|
||||
response = split(response, "<|")[1]
|
||||
response = split(response, "</")[1]
|
||||
response = _response
|
||||
|
||||
return response
|
||||
end
|
||||
@@ -1275,20 +1272,17 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
|
||||
a.attemptlimit = attemptlimit
|
||||
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.
|
||||
@@ -1297,10 +1291,8 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
|
||||
response = split(response, "\n\n")[1]
|
||||
response = split(response, "\n\n")[1]
|
||||
end
|
||||
|
||||
response = removeTrailingCharacters(response)
|
||||
_ = addNewMessage(a, "assistant", response)
|
||||
|
||||
return response
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user