update makeSummary()

This commit is contained in:
2023-11-19 01:29:42 +00:00
parent d016ba37cf
commit 1658041f0e

View File

@@ -91,7 +91,7 @@ function agentReact(
thinkingMode::Dict=Dict(
:nothinking=> "",
:react=>
"Use the following format:
"""Use the following format:
Question: the input question your user is asking and you must answer
Plan: first you should always think about the question and the info you have thoroughly then extract and devise a complete plan to find the answer (pay attention to variables and their corresponding numerals).
Thought: ask yourself do you have all the info you need? And what to do (pay attention to correct numeral calculation and commonsense).
@@ -100,8 +100,10 @@ function agentReact(
Obs: the result of the action
... (this Plan/Thought/Act/ActInput/Obs loop can repeat N times until you know the answer.)
Answer: Answer of the original question.
When you get "No info available." 3 times in a row, just answer the question.
Begin!",
Begin!""",
),
tools::Dict=Dict(
:wikisearch=>Dict(
@@ -393,7 +395,7 @@ function work(a::T, prompt::String) where {T<:agent}
thought *= "$header $body"
end
a.thought = thought
else #WORKING make sure respond is numbered
else
a.thought *= respond
end
@@ -420,7 +422,6 @@ function work(a::T, prompt::String) where {T<:agent}
@show toolname
@show toolinput
if toolname == "chatbox" # chat with user
a.thought *= toolinput
respond = toolinput
@@ -434,7 +435,6 @@ function work(a::T, prompt::String) where {T<:agent}
_result = makeSummary(a, _result)
end
result = "Obs $(a.thoughtround): $_result\n"
# result = "Obs: I found the following info. AMD is a semiconductor company making a CPU\n" #TESTING
@show result
a.thought *= result
prompt = a.thought
@@ -516,7 +516,9 @@ function makeSummary(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
prompt =
"""
<|im_start|>system
You are a helpful assistant. Your job is to make a concise summary of a given text.
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.".
<|im_end|>
<|im_start|>user
@@ -526,8 +528,11 @@ function makeSummary(a::T1, input::T2) where {T1<:agent, T2<:AbstractString}
"""
prompt = replace(prompt, "{input}" => input)
println("---")
@show prompt
result = sendReceivePrompt(a, prompt)
@show result
println("===")
summary = result === nothing ? "nothing" : result
summary = replace(summary, "<|im_end|>" => "")
if summary[1:1] == "\n"
@@ -872,10 +877,14 @@ function wikisearch(phrase::T) where {T<:AbstractString}
return "Sorry, I couldn't find any Wikipedia page for the given phrase."
end
result = "No info available."
result = nothing
try
result = json_data["query"]["pages"][page_id]["extract"]
catch
result = "No info available."
end
if result == ""
result = "No info available."
end
return result
end