This commit is contained in:
2024-01-15 18:56:11 +00:00
parent 0f59725ac4
commit 00cee37b76
2 changed files with 25 additions and 17 deletions

View File

@@ -220,7 +220,8 @@ function planner_mistral_openorca(a::agentReflex)
Plan:
"""
plan = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=1024, temperature=0.1, stopword=["<|user|>", "</"])
plan = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=1024, temperature=0.1,
timeout=180, stopword=["<|user|>", "</"])
plan = split(plan, "<|")[1]
# plan = split(plan, "\n\n")[1]
@@ -520,7 +521,7 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
# headers = detectCharacters(response, headerToDetect)
println("")
headerToDetect = ["Plan $(a.attempt):",
@@ -538,14 +539,17 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
check_2 = haskey(chunkedtext, "Act $latestTask:")
check_3 = haskey(chunkedtext, "Actinput $latestTask:")
# check whether the act has valid json
# check_4 = false
# try
# act = GeneralUtils.getStringBetweenCharacters(response, '{', '}', endCharLocation="end")
# act = JSON3.read(act)
# check_4 = true
# catch
# end
#check whether the act has valid json
check_7 = true
if occursin('{', response)
try
act = GeneralUtils.getStringBetweenCharacters(response, '{', '}', endCharLocation="end")
act = JSON3.read(act)
check_7 = true
catch
check_7 = false
end
end
# check for a valid toolname
check_4 = false
@@ -562,12 +566,15 @@ function actor_mistral_openorca(a::agentReflex, selfaware=nothing)
check_6 = length(chunkedtext["Actinput $latestTask:"]) > 5
# print all check_1 to check_6
println("check_1: $check_1, check_2: $check_2, check_3: $check_3, check_4: $check_4, check_5: $check_5, check_6: $check_6")
println("check_1: $check_1, check_2: $check_2, check_3: $check_3, check_4: $check_4,
check_5: $check_5, check_6: $check_6, check_7: $check_7")
if check_1 && check_2 && check_3 && check_4 && check_5 && check_6
if check_1 && check_2 && check_3 && check_4 && check_5 && check_6 && check_7
#WORKING paraphrase selfaware
break
end
@show response
end
toolname = toolNameBeingCalled(chunkedtext["Act $latestTask:"], a.tools)
@@ -920,7 +927,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:"] = a.messages[end][:content]
a.memory[:shortterm]["Obs $latestTask:"] = "(user response) " * a.messages[end][:content]
end
end
end
@@ -1202,7 +1209,7 @@ function grading(a, guideline::T, text::T) where {T<:AbstractString}
prompt_grading = prompt
@show prompt_grading
println("")
response = sendReceivePrompt(a, prompt)
response = sendReceivePrompt(a, prompt, timeout=180)
response = "{" * split(response, "}")[1] * "}"
@show response
@show jsonresponse = JSON3.read(response)