update makeSummary()
This commit is contained in:
@@ -73,6 +73,7 @@ function agentReact(
|
||||
:assistant =>
|
||||
"""
|
||||
You are a helpful assistant that answer the user's questions as best you can.
|
||||
You should only ask user when you need more context.
|
||||
""",
|
||||
:sommelier =>
|
||||
"""
|
||||
@@ -394,7 +395,6 @@ function work(a::T, prompt::String, maxround::Int=3) where {T<:agent}
|
||||
toolname = nothing
|
||||
toolinput = nothing
|
||||
|
||||
#WORKING force answer if thoughtround exceed limit
|
||||
if a.thoughtround > a.thoughtlimit
|
||||
a.thought *= "Thought $(a.thoughtround): I think I know the answer."
|
||||
prompt = a.thought
|
||||
@@ -430,8 +430,10 @@ function work(a::T, prompt::String, maxround::Int=3) where {T<:agent}
|
||||
Act = findDetectedCharacter(headers, "Act $(a.thoughtround):")
|
||||
if length(Answer) == 1 && length(Act) == 0
|
||||
a.thought = "nothing" # question finished, no more thought
|
||||
a.context = "nothing"
|
||||
a.thoughtround = 0
|
||||
respond = chunkedtext[AnswerInd][:body]
|
||||
respond = replace(respond, "<|im_end|>"=>"")
|
||||
_ = addNewMessage(a, "assistant", respond)
|
||||
break
|
||||
else
|
||||
@@ -454,7 +456,7 @@ function work(a::T, prompt::String, maxround::Int=3) where {T<:agent}
|
||||
else
|
||||
toolinput = GeneralUtils.getStringBetweenCharacters(toolinput, " ", "\n")
|
||||
end
|
||||
@show toolname #BUG llm not specify tools
|
||||
@show toolname
|
||||
@show toolinput
|
||||
if toolname === nothing || toolinput === nothing
|
||||
println("toolname $toolname toolinput $toolinput retry thinking")
|
||||
@@ -470,7 +472,7 @@ function work(a::T, prompt::String, maxround::Int=3) where {T<:agent}
|
||||
body = i[:body]
|
||||
thought *= "$header $body"
|
||||
end
|
||||
a.thought = prompt * thought #BUG should be prompt + thought
|
||||
a.thought = prompt * thought
|
||||
else
|
||||
a.thought *= respond
|
||||
end
|
||||
@@ -571,7 +573,7 @@ end
|
||||
# else
|
||||
# toolinput = GeneralUtils.getStringBetweenCharacters(toolinput, " ", "\n")
|
||||
# end
|
||||
# @show toolname #BUG llm not specify tools
|
||||
# @show toolname
|
||||
# @show toolinput
|
||||
|
||||
|
||||
@@ -666,12 +668,15 @@ function conversationSummary(a::T) where {T<:agent}
|
||||
end
|
||||
|
||||
function makeSummary(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
||||
summary = "Nothing."
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
You are a helpful assistant.
|
||||
Your job is to make a concise summary of a given text.
|
||||
If you can't summarize say, "No info available.".
|
||||
Your need to determine now whether you can make a summary of user's text.
|
||||
|
||||
You have the following choices:
|
||||
If you cannot make a summary say, "{no}".
|
||||
If you can make a summary say, "{yes}".
|
||||
<|im_end|>
|
||||
|
||||
<|im_start|>user
|
||||
@@ -680,12 +685,29 @@ function makeSummary(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
|
||||
<|im_start|>assistant
|
||||
|
||||
"""
|
||||
prompt = replace(prompt, "{input}" => input)
|
||||
prompt = replace(prompt, "{input}" => usermsg)
|
||||
result = sendReceivePrompt(a, prompt)
|
||||
summary = result === nothing ? "nothing" : result
|
||||
summary = replace(summary, "<|im_end|>" => "")
|
||||
if summary[1:1] == "\n"
|
||||
summary = summary[2:end]
|
||||
result = GeneralUtils.getStringBetweenCharacters(result, "{", "}")
|
||||
if result == "yes"
|
||||
prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
You are a helpful assistant.
|
||||
Your job is to make a concise summary of user's text.
|
||||
<|im_end|>
|
||||
|
||||
<|im_start|>user
|
||||
{input}
|
||||
<|im_end|>
|
||||
<|im_start|>assistant
|
||||
|
||||
"""
|
||||
prompt = replace(prompt, "{input}" => input)
|
||||
result = sendReceivePrompt(a, prompt)
|
||||
summary = replace(result, "<|im_end|>" => "")
|
||||
if summary[1:1] == "\n"
|
||||
summary = summary[2:end]
|
||||
end
|
||||
end
|
||||
|
||||
return summary
|
||||
|
||||
Reference in New Issue
Block a user