update
This commit is contained in:
@@ -2,7 +2,7 @@ module interface
|
||||
|
||||
|
||||
export agentReact, agentReflex,
|
||||
addNewMessage, clearMessage, removeLatestMsg, conversation, writeEvaluationGuidlines,
|
||||
addNewMessage, clearMessage, removeLatestMsg, conversation, writeEvaluationGuideline,
|
||||
grading, analyze, selfReflext
|
||||
|
||||
using JSON3, DataStructures, Dates, UUIDs, HTTP
|
||||
@@ -604,9 +604,12 @@ end
|
||||
|
||||
|
||||
function work(a::agentReflex, usermsg::String)
|
||||
evaluationGuideline = nothing
|
||||
|
||||
if a.thinkingmode == :new_thinking
|
||||
a.earlierConversation = conversationSummary(a)
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
evaluationGuideline = writeEvaluationGuidlines(a, usermsg)
|
||||
elseif a.thinkingmode == :continue_thinking
|
||||
error("continue_thinking")
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
@@ -615,6 +618,8 @@ function work(a::agentReflex, usermsg::String)
|
||||
error("undefined condition thinkingmode = $thinkingmode")
|
||||
end
|
||||
|
||||
|
||||
|
||||
while true # Work loop
|
||||
# plan
|
||||
a.attempt += 1
|
||||
@@ -644,7 +649,8 @@ function work(a::agentReflex, usermsg::String)
|
||||
return msgToUser
|
||||
end
|
||||
|
||||
# evaluate
|
||||
# if
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -656,6 +662,18 @@ end
|
||||
|
||||
"""
|
||||
Actor function.
|
||||
|
||||
Args:
|
||||
a, one of ChatAgent's agent.
|
||||
plan, a step by step plan to respond
|
||||
|
||||
Return:
|
||||
case 1) if actor complete the plan successfully.
|
||||
actorState = "all steps done" inidicates that all step in plan were done.
|
||||
msgToUser = nothing.
|
||||
case 2) if actor needs to talk to user for more context
|
||||
actorState = "chatbox"
|
||||
msgToUser = "message from assistant to user"
|
||||
|
||||
"""
|
||||
function actor(a::agentReflex, plan::T) where {T<:AbstractString}
|
||||
@@ -705,6 +723,7 @@ function actor(a::agentReflex, plan::T) where {T<:AbstractString}
|
||||
end
|
||||
else #TODO finish all steps
|
||||
actorState = "all steps done"
|
||||
msgToUser = nothing
|
||||
error("actor done 2")
|
||||
break
|
||||
end
|
||||
@@ -719,7 +738,7 @@ end
|
||||
|
||||
Args:
|
||||
a, one of ChatAgent's agent.
|
||||
shorttermMemory, a short term memory that logs what happened.
|
||||
usermsg, stimulus e.g. question, task and etc.
|
||||
|
||||
Return:
|
||||
An evaluation guideline used to guage AI's work.
|
||||
@@ -729,23 +748,12 @@ Return:
|
||||
```jldoctest
|
||||
julia> using ChatAgent, CommUtils
|
||||
julia> agent = ChatAgent.agentReflex("Jene")
|
||||
julia> shorttermMemory =
|
||||
"
|
||||
user: What's AMD latest product?
|
||||
assistant: Plan 1: To provide the user with information about AMD's latest product, I will search for the most recent product release from AMD.
|
||||
1. Search for \"AMD latest product\" using wikisearch tool.
|
||||
2. Identify the most recent product release mentioned in the search results.
|
||||
3. Provide the user with the name of the latest product.
|
||||
|
||||
Thought 1: The user wants to know about the latest AMD products, so I should use the wikisearch tool to find information on this topic.
|
||||
Act 1: wikisearch
|
||||
ActInput 1: \"AMD latest product\"
|
||||
Obs 1: No info available.
|
||||
julia> usermsg = "What's AMD latest product?"
|
||||
"
|
||||
julia> evaluationGuideLine = ChatAgent.writeEvaluationRules(agent, shorttermMemory)
|
||||
julia> evaluationGuideLine = writeEvaluationGuideline(agent, usermsg)
|
||||
```
|
||||
"""
|
||||
function writeEvaluationGuidlines(a::agentReflex, shorttermMemory::T) where {T<:AbstractString}
|
||||
function writeEvaluationGuideline(a::agentReflex, usermsg::T) where {T<:AbstractString}
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
@@ -754,7 +762,7 @@ function writeEvaluationGuidlines(a::agentReflex, shorttermMemory::T) where {T<
|
||||
wikisearch: Useful for when you need to search an encyclopedia Input is keywords and not a question.
|
||||
|
||||
Your work:
|
||||
$shorttermMemory
|
||||
$usermsg
|
||||
|
||||
Your job are:
|
||||
1. Write an evaluation guideline for your work in order to be able to evaluate your respond.
|
||||
@@ -910,7 +918,7 @@ julia> report =
|
||||
source or search engine to find the most recent product release. Additionally, I could ask
|
||||
the user for more context or clarify their question to better understand what they are
|
||||
looking for."
|
||||
julia> lesson = analyze(agent, report)
|
||||
julia> lesson = selfReflext(agent, report)
|
||||
```
|
||||
"""
|
||||
function selfReflext(a, report::T) where {T<:AbstractString}
|
||||
|
||||
Reference in New Issue
Block a user