update
This commit is contained in:
@@ -205,7 +205,7 @@ function chat_mistral_openorca(a::agentReflex, usermsg::String)
|
||||
{context} =
|
||||
"
|
||||
{earlierConversation}
|
||||
{env status}
|
||||
{env state}
|
||||
{shortterm memory}
|
||||
{longterm memory}
|
||||
"
|
||||
@@ -268,7 +268,7 @@ function planner_mistral_openorca(a::agentReflex, usermsg::String)
|
||||
{context} =
|
||||
"
|
||||
{earlierConversation}
|
||||
{env status}
|
||||
{env state}
|
||||
{shortterm memory}
|
||||
{longterm memory}
|
||||
"
|
||||
@@ -317,6 +317,77 @@ function planner_mistral_openorca(a::agentReflex, usermsg::String)
|
||||
return prompt
|
||||
end
|
||||
|
||||
function actor_mistral_openorca(a::agentReflex, usermsg::T) where {T<:AbstractString}
|
||||
"""
|
||||
general prompt format:
|
||||
|
||||
"
|
||||
<|im_start|>system
|
||||
{role}
|
||||
{tools}
|
||||
{thinkingFormat}
|
||||
<|im_end|>
|
||||
{context}
|
||||
<|im_start|>user
|
||||
{usermsg}
|
||||
<|im_end|>
|
||||
<|im_start|>assistant
|
||||
|
||||
"
|
||||
|
||||
Note:
|
||||
{context} =
|
||||
"
|
||||
{earlierConversation}
|
||||
{env state}
|
||||
{shortterm memory}
|
||||
{longterm memory}
|
||||
"
|
||||
"""
|
||||
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
{role}
|
||||
{tools}
|
||||
{thinkingFormat}
|
||||
<|im_end|>
|
||||
{context}
|
||||
<|im_start|>user
|
||||
{usermsg}
|
||||
<|im_end|>
|
||||
<|im_start|>assistant
|
||||
|
||||
"""
|
||||
error("actor_mistral_openorca done")
|
||||
prompt = replace(prompt, "{role}" => a.roles[a.role])
|
||||
prompt = replace(prompt, "{thinkingFormat}" => a.thinkingFormat[:actor])
|
||||
toolnames = ""
|
||||
toollines = ""
|
||||
for (toolname, v) in a.tools
|
||||
toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
|
||||
toollines *= toolline
|
||||
toolnames *= "$toolname,"
|
||||
end
|
||||
prompt = replace(prompt, "{toolnames}" => toolnames)
|
||||
prompt = replace(prompt, "{tools}" => "You have access to the following tools:\n$toollines")
|
||||
|
||||
context =
|
||||
"""
|
||||
{earlierConversation}
|
||||
{current status}
|
||||
{longterm memory}
|
||||
"""
|
||||
context = replace(context, "{earlierConversation}" => "My earlier talk with the user:\n$(a.earlierConversation)")
|
||||
context = replace(context, "{current status}" => "")
|
||||
context = replace(context, "{longterm memory}" => "")
|
||||
|
||||
prompt = replace(prompt, "{context}" => context)
|
||||
|
||||
prompt = replace(prompt, "{usermsg}" => "Assignment: $usermsg")
|
||||
|
||||
return prompt
|
||||
end
|
||||
|
||||
"""
|
||||
Chat with llm.
|
||||
@@ -553,17 +624,21 @@ function work(a::agentReflex, usermsg::String)
|
||||
respond = sendReceivePrompt(a, prompt)
|
||||
plan = split(respond, "<|im_end|>")[1]
|
||||
@show respond
|
||||
step = 0
|
||||
while true
|
||||
step += 1
|
||||
isstep, stepdetail = extractStepFromPlan(a, plan, step)
|
||||
a.step = 0
|
||||
while true # execute step by step
|
||||
a.step += 1
|
||||
isstep, task = extractStepFromPlan(a, plan)
|
||||
@show isstep
|
||||
@show stepdetail
|
||||
@show task
|
||||
if isstep
|
||||
|
||||
respond = actor_mistral_openorca(a, task)
|
||||
error("work done")
|
||||
else # finish all steps
|
||||
break
|
||||
end
|
||||
|
||||
|
||||
error("work done")
|
||||
|
||||
end
|
||||
# evaluate
|
||||
|
||||
@@ -1033,12 +1108,12 @@ function chunktext(text::T, headers) where {T<:AbstractString}
|
||||
end
|
||||
|
||||
|
||||
function extractStepFromPlan(a::agent, plan::T, stepToExtract::Int) where {T<:AbstractString}
|
||||
function extractStepFromPlan(a::agent, plan::T) where {T<:AbstractString}
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
You are a helpful assistant.
|
||||
Your job is to determine whether step {$stepToExtract} is in the user plan.
|
||||
Your job is to determine whether step {$(a.step)} is in the user plan.
|
||||
|
||||
Choose one of the following choices:
|
||||
If there isn't say, {no}.
|
||||
|
||||
Reference in New Issue
Block a user