From 2de1e7d6d81e7c4b0bbbfcdc54f791be5a174d83 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 21 Feb 2024 18:37:56 +0700 Subject: [PATCH] update --- src/interface.jl | 42 ++++++++++++++++++++++++++++++++++++++---- src/utils.jl | 12 +++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index 0c5fa29..5349f7d 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -199,10 +199,43 @@ function planner_mistral_openorca(a::agentReflex) $(a.roleSpecificInstruction[a.role]) """ + # assistant_plan_prompt = + # """ + # + # <|system|> + # + # $aboutYourself + # + # + # $toollines + # + # $shorttermMemory + # + # + # 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. + # + # + # 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) + # 4. Ask the user about their price range + # 5. Use inventory tool to find cars that match the user's preferences and are within their price range + # 6. 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} + # + # + # $conversation + # <|assistant|> + # Plan: + # """ + assistant_plan_prompt = """ - - <|system|> + <|im_start|>system $aboutYourself @@ -227,12 +260,13 @@ function planner_mistral_openorca(a::agentReflex) 6. 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} - + <|im_end|> $conversation - <|assistant|> + <|im_start|>assistant Plan: """ + response = sendReceivePrompt(a, assistant_plan_prompt, max_tokens=1024, temperature=0.1, timeout=180, stopword=["<|user|>", " messagesToString(agent.messages) "<|im_start|>user: Hi there.\n<|im_end|><|im_start|>assistant: Hello! How can I assist you today?\n<|im_end|>" ``` -""" +""" function messagesToString(messages::AbstractVector{T}; addressAIas="assistant") where {T<:AbstractDict} conversation = "" if length(messages)!= 0 @@ -489,9 +489,9 @@ function messagesToString(messages::AbstractVector{T}; addressAIas="assistant") end if role == "user" - conversation *= "<|$role|>\n $(content[1:end-nouse])\n" + conversation *= "<|im_start|>$role\n $(content[1:end-nouse])\n<|im_end|>" elseif role == "assistant" - conversation *= "<|$addressAIas|>\n $(content[1:end-nouse])\n" + conversation *= "<|im_start|>$addressAIas\n $(content[1:end-nouse])\n<|im_end|>" else error("undefied condition role = $role $(@__LINE__)") end @@ -502,6 +502,7 @@ function messagesToString(messages::AbstractVector{T}; addressAIas="assistant") return conversation end + # function messagesToString(messages::AbstractVector{T}; addressAIas="assistant") where {T<:AbstractDict} # conversation = "" # if length(messages)!= 0 @@ -519,9 +520,9 @@ end # end # if role == "user" -# conversation *= "<|$role|>\n $(content[1:end-nouse])\n" +# conversation *= "<|$role|>\n $(content[1:end-nouse])\n" # elseif role == "assistant" -# conversation *= "<|$addressAIas|>\n $(content[1:end-nouse])\n" +# conversation *= "<|$addressAIas|>\n $(content[1:end-nouse])\n" # else # error("undefied condition role = $role $(@__LINE__)") # end @@ -534,6 +535,7 @@ end # end + """ Convert a vector of dict into 1-continous string. Arguments: