update
This commit is contained in:
@@ -3,7 +3,8 @@ module interface
|
||||
|
||||
export agentReact, agentReflex,
|
||||
addNewMessage, clearMessage, removeLatestMsg, conversation, writeEvaluationGuideline,
|
||||
grading, analyze, selfReflext, actor_mistral_openorca2, formulateUserRespond
|
||||
grading, analyze, selfReflext, actor_mistral_openorca2, formulateUserRespond,
|
||||
extractinfo, updateEnvState
|
||||
|
||||
using JSON3, DataStructures, Dates, UUIDs, HTTP
|
||||
using CommUtils, GeneralUtils
|
||||
@@ -453,25 +454,24 @@ function conversation(a::agentReflex, usermsg::String; attemptlimit::Int=3)
|
||||
respond = nothing
|
||||
|
||||
a.earlierConversation = conversationSummary(a)
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
isusetools = isUseTools(a, usermsg)
|
||||
|
||||
# determine thinking mode
|
||||
a.thinkingmode = chooseThinkingMode(a, usermsg)
|
||||
@show a.thinkingmode
|
||||
|
||||
if a.thinkingmode == :no_thinking
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
prompt = chat_mistral_openorca(a, usermsg)
|
||||
println("")
|
||||
@show prompt
|
||||
respond = sendReceivePrompt(a, prompt)
|
||||
respond = split(respond, "<|im_end|>")[1]
|
||||
respond = replace(respond, "\n" => "")
|
||||
_ = addNewMessage(a, "assistant", respond)
|
||||
println("")
|
||||
@show respond
|
||||
else
|
||||
#WORKING
|
||||
if isusetools # use tools before responding
|
||||
respond = work(a, usermsg)
|
||||
end
|
||||
|
||||
#WORKING
|
||||
prompt = chat_mistral_openorca(a, usermsg)
|
||||
println("")
|
||||
@show prompt
|
||||
respond = sendReceivePrompt(a, prompt)
|
||||
respond = split(respond, "<|im_end|>")[1]
|
||||
respond = replace(respond, "\n" => "")
|
||||
_ = addNewMessage(a, "assistant", respond)
|
||||
println("")
|
||||
@show respond
|
||||
|
||||
return respond
|
||||
end
|
||||
@@ -1110,13 +1110,68 @@ function goNogo(a)
|
||||
end
|
||||
|
||||
|
||||
#WORKING
|
||||
""" Determine whether LLM should go to next step.
|
||||
|
||||
Args:
|
||||
a, one of ChatAgent's agent.
|
||||
|
||||
Return:
|
||||
"Yes" or "no" decision to go next step.
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> using ChatAgent, CommUtils
|
||||
julia> agent = ChatAgent.agentReflex("Jene")
|
||||
julia> shorttermMemory = OrderedDict{String, Any}(
|
||||
"user:" => "What's the latest AMD GPU?",
|
||||
"Plan 1:" => " To answer this question, I will need to search for the latest AMD GPU using the wikisearch tool.\n",
|
||||
"Act 1:" => " wikisearch\n",
|
||||
"Actinput 1:" => " amd gpu latest\n",
|
||||
"Obs 1:" => "No info available for your search query.",
|
||||
"Act 2:" => " wikisearch\n",
|
||||
"Actinput 2:" => " amd graphics card latest\n",
|
||||
"Obs 2:" => "No info available for your search query.")
|
||||
|
||||
julia> decision = goNogo(agent)
|
||||
"Yes"
|
||||
```
|
||||
"""
|
||||
function extractinfo(a, msg)
|
||||
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
User message:
|
||||
$msg
|
||||
|
||||
Your job is to extract important info from user's message into keys and values using this format: key=value ,.
|
||||
p.s.1 you can extract many key-value pairs.
|
||||
<|im_end|>
|
||||
|
||||
"""
|
||||
|
||||
respond = sendReceivePrompt(a, prompt, temperature=0.0)
|
||||
end
|
||||
|
||||
|
||||
function updateEnvState(a, currentinfo, newinfo)
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
Current state:
|
||||
$currentinfo
|
||||
|
||||
New info:
|
||||
$newinfo
|
||||
|
||||
Your job is to update or add information from new info into the current state which use key-value format.
|
||||
<|im_end|>
|
||||
Updated Current State:\n
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
respond = sendReceivePrompt(a, prompt, temperature=0.0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user