From d659202c05e3be07cf1d0d05822c147a6178c905 Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Thu, 23 Nov 2023 12:50:24 +0000 Subject: [PATCH] update --- src/interface.jl | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index 13a7c36..9d9e171 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -4,7 +4,7 @@ module interface export agentReact, agentReflex, addNewMessage, clearMessage, removeLatestMsg, generatePrompt_tokenPrefix, generatePrompt_tokenSuffix, conversation, work, detectCharacters, chunktext, - findDetectedCharacter, wikisearch, sendReceivePrompt + findDetectedCharacter, wikisearch, sendReceivePrompt, extractStepFromPlan using JSON3, DataStructures, Dates, UUIDs, HTTP using CommUtils, GeneralUtils @@ -618,14 +618,15 @@ function work(a::agentReflex, usermsg::String) a.attempt += 1 @show a.attempt @show usermsg - # a.thoughtlog *= + a.thoughtlog *= "$usermsg\n" toolname = nothing toolinput = nothing prompt = planner_mistral_openorca(a, usermsg) @show prompt respond = sendReceivePrompt(a, prompt) plan = split(respond, "<|im_end|>")[1] - @show respond + @show plan + a.thoughtlog *= plan a.step = 0 while true # execute step by step a.step += 1 @@ -634,9 +635,11 @@ function work(a::agentReflex, usermsg::String) @show task if isstep respond = actor_mistral_openorca(a, task) - error("work done") + error("work done 1") else # finish all steps + error("work done 2") break + end @@ -1130,16 +1133,29 @@ function extractStepFromPlan(a::agent, plan::T) where {T<:AbstractString} """ isStep = nothing step = nothing - respond = sendReceivePrompt(a, prompt) - isStep = GeneralUtils.getStringBetweenCharacters(respond, "{", "}") - if isStep == "no" - isStep = false - step = "nothing" - elseif isStep == "yes" - isStep = true - step = split(respond, "{yes}")[end] - else - error("undefined condition. isStep=$isStep $(@__LINE__)") + for i in 1:3 + @show prompt + respond = sendReceivePrompt(a, prompt) + @show respond + isStep = GeneralUtils.getStringBetweenCharacters(respond, "{", "}") + @show isStep + if isStep == "no" + isStep = false + step = "nothing" + break + elseif isStep == "yes" + isStep = true + step = split(respond, "{yes}")[end] + break + else + # keep trying + isStep = nothing + step = nothing + end + end + + if isStep === nothing && step === nothing + error("undefined condition. step $(a.step) isStep=$isStep $(@__LINE__)") end return isStep, step