update
This commit is contained in:
@@ -47,15 +47,15 @@ using ..type, ..utils, ..llmfunction
|
||||
julia> addNewMessage(agent1, "user", "Where should I go to buy snacks")
|
||||
```
|
||||
"""
|
||||
function addNewMessage(a::T1, role::String, content::T2) where {T1<:agent, T2<:AbstractString}
|
||||
if role ∉ a.availableRole # guard against typo
|
||||
error("role is not in agent.availableRole $(@__LINE__)")
|
||||
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
|
||||
|
||||
# check whether user messages exceed limit
|
||||
userMsg = 0
|
||||
for i in a.messages
|
||||
if i[:role] == "user"
|
||||
if i[:name] == "user"
|
||||
userMsg += 1
|
||||
end
|
||||
end
|
||||
@@ -66,7 +66,7 @@ function addNewMessage(a::T1, role::String, content::T2) where {T1<:agent, T2<:A
|
||||
messageleft = a.maxUserMsg
|
||||
else
|
||||
userMsg += 1
|
||||
d = Dict(:role=> role, :content=> content, :timestamp=> Dates.now())
|
||||
d = Dict(:name=> name, :text=> content, :timestamp=> Dates.now())
|
||||
push!(a.messages, d)
|
||||
messageleft = a.maxUserMsg - userMsg
|
||||
end
|
||||
@@ -95,7 +95,66 @@ function removeLatestMsg(a::T) where {T<:agent}
|
||||
end
|
||||
end
|
||||
|
||||
function chat_mistral_openorca(a::agentReflex)
|
||||
# function chat_mistral_openorca(a::agentReflex, prompttemplate="llama3")
|
||||
|
||||
|
||||
|
||||
|
||||
# """
|
||||
# general prompt format:
|
||||
|
||||
# "
|
||||
# <|system|>
|
||||
# {role}
|
||||
# {tools}
|
||||
# {thinkingFormat}
|
||||
# {context}
|
||||
# <|im_end|>
|
||||
# <|im_start|>user
|
||||
# {usermsg}
|
||||
# <|im_end|>
|
||||
# <|im_start|>assistant
|
||||
|
||||
# "
|
||||
|
||||
# Note:
|
||||
# {context} =
|
||||
# "
|
||||
# {earlierConversation}
|
||||
# {env state}
|
||||
# {shortterm memory}
|
||||
# {longterm memory}
|
||||
# "
|
||||
# """
|
||||
|
||||
# conversation = messagesToString(a.messages)
|
||||
|
||||
# aboutYourself =
|
||||
# """
|
||||
# Your name is $(a.name)
|
||||
# $(a.roles[a.role])
|
||||
# """
|
||||
|
||||
# prompt =
|
||||
# """
|
||||
# <|system|>
|
||||
# <About yourself>
|
||||
# $aboutYourself
|
||||
# </About yourself>
|
||||
# </s>
|
||||
# $conversation
|
||||
# <|assistant|>
|
||||
# """
|
||||
|
||||
# response = sendReceivePrompt(a, prompt, a.config[:text2textchat][:mqtttopic],
|
||||
# timeout=180, stopword=["<|", "</"])
|
||||
# response = split(response, "<|")[1]
|
||||
# response = split(response, "</")[1]
|
||||
|
||||
# return response
|
||||
# end
|
||||
|
||||
function chat_mistral_openorca(a::agentReflex, prompttemplate="llama3")
|
||||
"""
|
||||
general prompt format:
|
||||
|
||||
@@ -123,23 +182,11 @@ function chat_mistral_openorca(a::agentReflex)
|
||||
"
|
||||
"""
|
||||
|
||||
conversation = messagesToString(a.messages)
|
||||
|
||||
aboutYourself =
|
||||
"""
|
||||
Your name is $(a.name)
|
||||
$(a.roles[a.role])
|
||||
"""
|
||||
conversation = formatLLMtext(a.messages, "llama3instruct")
|
||||
|
||||
prompt =
|
||||
"""
|
||||
<|system|>
|
||||
<About yourself>
|
||||
$aboutYourself
|
||||
</About yourself>
|
||||
</s>
|
||||
$conversation
|
||||
<|assistant|>
|
||||
"""
|
||||
|
||||
response = sendReceivePrompt(a, prompt, a.config[:text2textchat][:mqtttopic],
|
||||
@@ -1275,7 +1322,7 @@ function work(a::agentReflex)
|
||||
latestTask = shortMemLatestTask(a.memory[:shortterm])
|
||||
if haskey(a.memory[:shortterm], "Act $latestTask:")
|
||||
if occursin("askbox", a.memory[:shortterm]["Act $latestTask:"])
|
||||
a.memory[:shortterm]["Obs $latestTask:"] = "(user response) " * a.messages[end][:content]
|
||||
a.memory[:shortterm]["Obs $latestTask:"] = "(user response) " * a.messages[end][:text]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user