This commit is contained in:
2024-01-19 13:11:08 +00:00
parent b419a5629c
commit c31d2e009d
3 changed files with 149 additions and 127 deletions

View File

@@ -362,14 +362,15 @@ function selfAwareness(a::agentReflex)
<Your earlier work>
$work
</Your earlier work>
<Your plan>
$(a.memory[:shortterm]["Plan 1:"])
</Your plan>
<Your job>
Use the following format strictly:
What do I know: based on observed results, repeat all the information you are gathering.
What do I know: based on observed results, repeat all the information you got.
Info match: explicitly state what information matches what variable in my plan.
What am I missing: based on observed results, describe in detail what you are still missing compared to your plan.
What am I missing: based on observed results, describe in detail what you are still missing based on the plan.
P.S. do not mention any toolnames
</Your job>
</s>
@@ -448,7 +449,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
# aware = "Self-awareness: Based on action's input and observed results, check your progress against the plan. Then, repeat all the details of what you have been gathered. Finally, describe in detail what you are missing."
thought =
"Self-awareness: $selfaware
Thought: based on self-awareness, think about what to do next and focus on what you missed first. (P.S. 1) let's think a single step. 2) pay attention to correct numeral calculation and commonsense.)
Thought: based on self-awareness, think about what to do next but focus on what you missed first. (P.S. 1) let's think a single step. 2) pay attention to correct numeral calculation and commonsense.)
"
end
@@ -458,6 +459,18 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
$(a.roles[a.role])
"""
winestocksearchresult = nothing
if haskey(a.memory, :winestocksearchresult) && a.memory[:winestockResult] !== nothing
winestocksearchresult =
"""
<winestock search result>
$(a.memory[:winestocksearchresult])
</winestock search result>
"""
else
winestocksearchresult = "\n"
end
prompt =
"""
<|system|>
@@ -470,6 +483,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
<Your plan>
$(a.memory[:shortterm]["Plan 1:"])
</Your plan>
<Your job>
Use the following format:
$thought
@@ -605,11 +619,13 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
"Check $latestTask:",]
headers = detectCharacters(response, headerToDetect)
chunkedtext = chunktext(response, headers)
println("")
@show chunkedtext
toolinput = chunkedtext["Actinput $latestTask:"]
# because tools has JSON input but sometime LLM output is not JSON, we need to check.
if occursin("{", toolinput)
act = GeneralUtils.getStringBetweenCharacters(response, '{', '}', endCharLocation="end")
@@ -870,9 +886,9 @@ function actor(a::agentReflex)
f = a.tools[toolname][:func]
toolresult = f(a, actorResult)
@show toolresult
if toolname == "temp"
a.winestockResult = toolresult
a.memory[:shortterm]["Obs $latestTask:"] = "winestock search done, refers to <winestock search result>"
if toolname == ""
a.memory[:shortterm]["Obs $latestTask:"] = "I found wines in <winestock search result>"
a.memory[:winestockResult] = toolresult
a.memory[:log]["Obs $latestTask:"] = "winestock search done"
else
a.memory[:shortterm]["Obs $latestTask:"] = toolresult
@@ -981,7 +997,7 @@ function grading(a, guideline::T, text::T) where {T<:AbstractString}
Evaluate your response using the evaluation guideline then give yourself a score out of 9 for your response.
</Your job>
<Example>
{"Evaluate": "Evaluate your response using the evaluation guideline.", "Score": 6}
{"Evaluate": "My response is detailed with good comparison between options.", "Score": 6}
</Example>
</s>
<|assistant|>
@@ -993,12 +1009,13 @@ function grading(a, guideline::T, text::T) where {T<:AbstractString}
println("")
score = nothing
while true
response = sendReceivePrompt(a, prompt, timeout=180a)
response = sendReceivePrompt(a, prompt, timeout=180)
try
response = "{" * split(response, "}")[1] * "}"
@show response
@show jsonresponse = JSON3.read(response)
score = jsonresponse["Score"]
break
catch
println("retry grading")
end