update
This commit is contained in:
@@ -187,6 +187,7 @@ function generatePrompt_mistral_openorca(a::T, usermsg::String,
|
||||
return prompt
|
||||
end
|
||||
|
||||
#WORKING
|
||||
function chat_mistral_openorca(a::agentReflex, usermsg::String)
|
||||
"""
|
||||
general prompt format:
|
||||
@@ -196,8 +197,8 @@ function chat_mistral_openorca(a::agentReflex, usermsg::String)
|
||||
{role}
|
||||
{tools}
|
||||
{thinkingFormat}
|
||||
<|im_end|>
|
||||
{context}
|
||||
<|im_end|>
|
||||
<|im_start|>user
|
||||
{usermsg}
|
||||
<|im_end|>
|
||||
@@ -218,34 +219,22 @@ function chat_mistral_openorca(a::agentReflex, usermsg::String)
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
{role}
|
||||
{thinkingFormat}
|
||||
$(a.roles[a.role])
|
||||
Your earlier talk with the user:
|
||||
$(a.earlierConversation)
|
||||
What you know about current situations:
|
||||
$(a.env)
|
||||
Begin!
|
||||
<|im_end|>
|
||||
{context}
|
||||
<|im_start|>user
|
||||
{usermsg}
|
||||
$usermsg
|
||||
<|im_end|>
|
||||
<|im_start|>assistant
|
||||
|
||||
"""
|
||||
prompt = replace(prompt, "{role}" => a.roles[a.role])
|
||||
prompt = replace(prompt, "{thinkingFormat}" => "")
|
||||
|
||||
context =
|
||||
"""
|
||||
{earlierConversation}
|
||||
{env state}
|
||||
{longterm memory}
|
||||
"""
|
||||
context = replace(context, "{earlierConversation}" => "My earlier talk with the user:\n$(a.earlierConversation)")
|
||||
context = replace(context, "{env state}" => "")
|
||||
context = replace(context, "{longterm memory}" => "")
|
||||
|
||||
prompt = replace(prompt, "{context}" => context)
|
||||
|
||||
prompt = replace(prompt, "{usermsg}" => "Stimulus: $usermsg")
|
||||
|
||||
return prompt
|
||||
response = sendReceivePrompt(a, prompt)
|
||||
response = split(response, "<|im_end|>")[1]
|
||||
return response
|
||||
end
|
||||
|
||||
|
||||
@@ -458,22 +447,15 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
|
||||
isusetools = isUseTools(a, usermsg)
|
||||
newinfo = extractinfo(a, usermsg)
|
||||
a.env = newinfo !== nothing ? updateEnvState(a, newinfo) : a.env
|
||||
error(1)
|
||||
#WORKING
|
||||
if isusetools # use tools before responseing
|
||||
response = work(a, usermsg)
|
||||
end
|
||||
|
||||
#WORKING
|
||||
prompt = chat_mistral_openorca(a, usermsg)
|
||||
println("")
|
||||
@show prompt
|
||||
response = sendReceivePrompt(a, prompt)
|
||||
response = split(response, "<|im_end|>")[1]
|
||||
response = replace(response, "\n" => "")
|
||||
# if isusetools # use tools before responseing
|
||||
# response = work(a, usermsg)
|
||||
# end
|
||||
|
||||
#WORKING
|
||||
response = chat_mistral_openorca(a, usermsg)
|
||||
_ = addNewMessage(a, "assistant", response)
|
||||
println("")
|
||||
@show response
|
||||
|
||||
return response
|
||||
end
|
||||
@@ -1250,7 +1232,7 @@ function extractinfo(a, text::T) where {T<:AbstractString}
|
||||
Your job is determine whether there are important info in the user's message. Answer: {Yes/No/Not sure}
|
||||
<|im_end|>
|
||||
Answer:
|
||||
"""
|
||||
"""
|
||||
response = sendReceivePrompt(a, prompt, temperature=0.0)
|
||||
if occursin("Yes", response)
|
||||
prompt =
|
||||
@@ -1263,7 +1245,7 @@ function extractinfo(a, text::T) where {T<:AbstractString}
|
||||
p.s.1 you can extract many key-value pairs.
|
||||
<|im_end|>
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
response = sendReceivePrompt(a, prompt, temperature=0.0)
|
||||
return response
|
||||
@@ -1308,6 +1290,7 @@ function updateEnvState(a, newinfo)
|
||||
"""
|
||||
|
||||
response = sendReceivePrompt(a, prompt, temperature=0.0)
|
||||
return response
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ julia> agent = ChatAgent.agentReflex(
|
||||
availableRole::AbstractVector = ["system", "user", "assistant"]
|
||||
agentName::String = "Jene" # ex. Jene
|
||||
maxUserMsg::Int = 30
|
||||
earlierConversation::String = "" # summary of earlier conversation
|
||||
earlierConversation::String = "N/A" # summary of earlier conversation
|
||||
mqttClient::Union{mqttClient, Nothing} = nothing
|
||||
msgMeta::Union{Dict, Nothing} = nothing
|
||||
|
||||
@@ -96,7 +96,7 @@ julia> agent = ChatAgent.agentReflex(
|
||||
attemptlimit::Int = 5 # thinking round limit
|
||||
attempt::Int = 0 # attempted number
|
||||
step::Int = 0 # step number
|
||||
env::AbstractString = ""
|
||||
env::AbstractString = "N/A"
|
||||
thinkingFormat::Union{Dict, Nothing} = nothing
|
||||
memory::Dict = Dict(
|
||||
:shortterm=> OrderedDict{String, Any}(),
|
||||
|
||||
Reference in New Issue
Block a user