update
This commit is contained in:
140
src/interface.jl
140
src/interface.jl
@@ -214,27 +214,44 @@ function planner_mistral_openorca(a::agentReflex)
|
||||
</Your earlier work>
|
||||
<Your job>
|
||||
Plan: first you should always think about your conversation with the user and your earlier work thoroughly then extract and devise a complete, task by task, plan to achieve your objective (pay attention to correct numeral calculation and commonsense).
|
||||
Keyword memory: using JSON format, list all variables in the plan you need to find out
|
||||
P.S.1 each task of the plan should be a single action.
|
||||
</Your job>
|
||||
<Example>
|
||||
Plan:
|
||||
1. Ask the user about how many miles per day they drive
|
||||
2. Ask the user about what stuff they usually carry with
|
||||
3. Ask the user about preferred type of car they want to buy (sedan, sport, SUV, etc)
|
||||
8. Ask the user about their price range
|
||||
9. Use inventory tool to find cars that match the user's preferences and are within their price range
|
||||
10. Use finalanswer tool to present the recommended car to the user.
|
||||
Keyword memory: {"mile per day": null, "carry item": null, "car type": null, "price range": null}
|
||||
</Example
|
||||
</s>
|
||||
$conversation
|
||||
<|assistant|>
|
||||
Plan:
|
||||
|
||||
"""
|
||||
# provide ecmaple that show good planning
|
||||
plan = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=1024, temperature=0.1,
|
||||
|
||||
response = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=1024, temperature=0.1,
|
||||
timeout=180, stopword=["<|user|>", "</"])
|
||||
plan = split(plan, "<|")[1]
|
||||
plan = split(plan, "</")[1]
|
||||
# plan = split(plan, "\n\n")[1]
|
||||
response = split(response, "<|")[1]
|
||||
response = split(response, "</")[1]
|
||||
response = split(response, "\n\n")[1]
|
||||
@show response
|
||||
|
||||
headerToDetect = ["Plan:", "Keyword memory:",]
|
||||
headers = detectCharacters(response, headerToDetect)
|
||||
@show headers
|
||||
chunkedtext = chunktext(response, headers)
|
||||
a.memory[:c] = chunkedtext
|
||||
|
||||
plan = chunkedtext["Plan:"]
|
||||
keywordmem = JSON3.read(chunkedtext["Keyword memory:"]) # use JSON to change from json string to dict
|
||||
|
||||
for (k, v) in keywordmem
|
||||
a.memory[:keyword][String(k)] = v
|
||||
end
|
||||
|
||||
return plan
|
||||
end
|
||||
@@ -394,6 +411,8 @@ end
|
||||
# end
|
||||
|
||||
function selfAwareness(a::agentReflex)
|
||||
latestTask = shortMemLatestTask(a.memory[:shortterm])
|
||||
|
||||
getonlykeys = ["Actinput", "Obs"]
|
||||
worknoplan = similar(a.memory[:shortterm])
|
||||
for (k, v) in a.memory[:shortterm]
|
||||
@@ -427,28 +446,32 @@ function selfAwareness(a::agentReflex)
|
||||
<Your earlier work>
|
||||
$work
|
||||
</Your earlier work>
|
||||
|
||||
<Your plan>
|
||||
$(a.memory[:shortterm]["Plan 1:"])
|
||||
</Your plan>
|
||||
<Your keyword memory>
|
||||
$(JSON3.write(a.memory[:keyword]))
|
||||
</Your keyword memory>
|
||||
<Your job>
|
||||
Use the following format strictly:
|
||||
What I know: based on observed results, breakdown then repeat all information you got one by one
|
||||
Info matching: using JSON format, explicitly state what information matches which variable name in my plan
|
||||
What am I missing: based on Info matching, describe in detail what you are still missing based on the plan
|
||||
P.S. do not mention any toolnames
|
||||
Info extraction: repeat all keywords from the latest observed result thoroughly
|
||||
Info mapping: based on extracted info, explicitly state what each keyword could match which keyword memory's key
|
||||
Info matching: using JSON format, what key in my memory matches which info
|
||||
</Your job>
|
||||
<Example>
|
||||
What do I know:
|
||||
- The user is buying an electric SUV car.
|
||||
<Your earlier work>
|
||||
The user wants to buy an electric SUV car.
|
||||
</Your earlier work>
|
||||
<Your keyword memory>
|
||||
{"car type": null, "color": null, "financing": null}
|
||||
</Your keyword memory>
|
||||
Info extraction:
|
||||
- The user is buying an electric SUV car.
|
||||
Info mapping:
|
||||
- SUV could matches "car type" key
|
||||
- electric could matches "engine type" key
|
||||
Info matching: {"car type": "SUV", "engine type": "electric motor", "color": null, "financing": null}
|
||||
What am I missing:
|
||||
- The user's preferred color
|
||||
- The user's financing method
|
||||
</Example>
|
||||
</s>
|
||||
<|assistant|>
|
||||
What I know:
|
||||
Info extraction:
|
||||
"""
|
||||
response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=0.2, timeout=180,
|
||||
stopword=["/n/n", "END", "End", "Obs", "<|", "</"])
|
||||
@@ -458,48 +481,52 @@ function selfAwareness(a::agentReflex)
|
||||
@show selfaware_1 = response
|
||||
|
||||
#WORKING
|
||||
headerToDetect = ["What I know:", "Info matching:", "What am I missing:",]
|
||||
headerToDetect = ["Info extraction:", "Info matching:",]
|
||||
headers = detectCharacters(response, headerToDetect)
|
||||
chunkedtext = chunktext(response, headers)
|
||||
println("")
|
||||
_infomatch = chunkedtext["Info matching:"]
|
||||
_infomatch = GeneralUtils.getStringBetweenCharacters(_infomatch, '{', '}', endCharLocation="next")
|
||||
infomatch = copy(JSON3.read(_infomatch))
|
||||
|
||||
println("")
|
||||
@show chunkedtext
|
||||
|
||||
|
||||
keywordMemoryUpdate!(a.memory[:keyword], infomatch)
|
||||
|
||||
prompt =
|
||||
"""
|
||||
<|system|>
|
||||
<About yourself>
|
||||
$aboutYourself
|
||||
$(a.roleSpecificInstruction[a.role])
|
||||
</About yourself>
|
||||
# prompt =
|
||||
# """
|
||||
# <|system|>
|
||||
# <About yourself>
|
||||
# $aboutYourself
|
||||
# $(a.roleSpecificInstruction[a.role])
|
||||
# </About yourself>
|
||||
|
||||
<Your plan>
|
||||
$(a.memory[:shortterm]["Plan 1:"])
|
||||
</Your plan>
|
||||
<Your job>
|
||||
Use the following format strictly:
|
||||
What am I missing: based on Info matching, describe in detail what you are still missing according to the plan
|
||||
P.S. do not mention any toolnames
|
||||
</Your job>
|
||||
<Example>
|
||||
Info matching: {"car type": "SUV", "engine type": "electric motor", "color": null, "financing": null}
|
||||
What am I missing:
|
||||
- The user's preferred color
|
||||
- The user's financing method
|
||||
</Example>
|
||||
</s>
|
||||
<|assistant|>
|
||||
Info matching: $(JSON3.write(a.memory[:keyword]))
|
||||
What am I missing:
|
||||
"""
|
||||
response = "What am I missing:" * sendReceivePrompt(a, prompt, max_tokens=1024, temperature=0.4, timeout=180,
|
||||
stopword=["/n/n", "END", "End", "Obs", "<|", "</"])
|
||||
response = split(response, "<|")[1]
|
||||
response = split(response, "</")[1]
|
||||
# <Your plan>
|
||||
# $(a.memory[:shortterm]["Plan 1:"])
|
||||
# </Your plan>
|
||||
# <Your job>
|
||||
# Use the following format strictly:
|
||||
# What I know: what you know in JSON format
|
||||
# What am I missing: based on what I know, list all items I am missing
|
||||
# P.S. do not mention any toolnames
|
||||
# </Your job>
|
||||
# <Example>
|
||||
# What I know: {"car type": "SUV", "engine type": "electric motor", "color": null, "financing": null}
|
||||
# What am I missing:
|
||||
# - The user's preferred color
|
||||
# - The user's financing method
|
||||
# </Example>
|
||||
# </s>
|
||||
# <|assistant|>
|
||||
# What I know: $(JSON3.write(a.memory[:keyword]))
|
||||
# """
|
||||
# response = sendReceivePrompt(a, prompt, max_tokens=1024, temperature=0.4, timeout=180,
|
||||
# stopword=["/n/n", "END", "End", "Obs", "<|", "</"])
|
||||
# response = split(response, "<|")[1]
|
||||
# response = split(response, "</")[1]
|
||||
|
||||
response = "Info matching:" * chunkedtext["Info matching:"] * response
|
||||
response = "What I know about user:" * JSON3.write(a.memory[:keyword]) # * response
|
||||
@show selfaware_2 = response
|
||||
|
||||
|
||||
@@ -562,15 +589,12 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
|
||||
push!(toolslist, toolname)
|
||||
end
|
||||
|
||||
println("")
|
||||
@show actor_selfaware = selfaware
|
||||
|
||||
thought = "Thought: you should always think about what to do according to the plan (pay attention to correct numeral calculation and commonsense and do one thing at a time.)"
|
||||
if selfaware !== nothing
|
||||
|
||||
thought =
|
||||
"Self-awareness: $selfaware
|
||||
Thought: To think about your next step, reflect on your self-awareness and prioritize what you need to improve first then consult your plan. (P.S. 1) let's think a single step. 2) pay attention to correct numeral calculation and commonsense.)
|
||||
"Self-awareness: $(JSON3.write(a.memory[:keyword]))
|
||||
Thought: To think about your next step, reflect on your self-awareness and prioritize what you need to improve first (null) then consult your plan. (P.S. 1) let's think a single step. 2) pay attention to correct numeral calculation and commonsense.)
|
||||
"
|
||||
end
|
||||
# your should request the missing information first before making a decision
|
||||
|
||||
Reference in New Issue
Block a user