This commit is contained in:
youremail@yourdomain.com
2023-12-20 13:10:40 +00:00
parent 15d00ae0a7
commit 1130268c73
3 changed files with 142 additions and 137 deletions

View File

@@ -2,9 +2,9 @@ module utils
export makeSummary, sendReceivePrompt, chunktext, extractStepFromPlan, checkTotalStepInPlan,
detectCharacters, findDetectedCharacter, extract_number, toolNameBeingCalled,
isUseTools, conversationSummary, checkReasonableness, replaceHeaders,
isUsePlans, conversationSummary, checkReasonableness, replaceHeaders,
addShortMem!, splittext, dictToString, removeHeaders, keepOnlyKeys, experience,
messagesToString, messagesToString_nomark, removeTrailingCharacters, dictLatestStep
messagesToString, messagesToString_nomark, removeTrailingCharacters, shortMemLatestStep
using UUIDs, Dates, DataStructures
using CommUtils, GeneralUtils
@@ -375,7 +375,7 @@ Return:
1. true/false # is LLM going to use tools
2. objective # what LLM going to do
"""
function isUseTools(a::agentReflex)
function isUsePlans(a::agentReflex)
toollines = ""
for (toolname, v) in a.tools
if toolname ["chatbox"] # LLM will always use chatbox
@@ -405,26 +405,26 @@ function isUseTools(a::agentReflex)
"""
# if LLM mentions any tools, use Plan/Thought/Act loop
isusetool = false
isuseplan = false
response = sendReceivePrompt(a, prompt, temperature=0.2, max_tokens=64)
response = split(response, "<|assistant|>")[1]
response = split(response, "<|user|>")[1]
@show response
for (toolname, v) in a.tools
if occursin("Yes", String(response))
isusetool = true
isuseplan = true
break
end
end
if length(a.memory[:shortterm]) != 0
isusetool = true
isuseplan = true
end
return isusetool
return isuseplan
end
# function isUseTools(a::agentReflex)
# function isUsePlans(a::agentReflex)
# toollines = ""
# for (toolname, v) in a.tools
# if toolname ∉ ["chatbox"] # LLM will always use chatbox
@@ -451,21 +451,21 @@ end
# """
# # if LLM mentions any tools, use Plan/Thought/Act loop
# isusetool = false
# isuseplan = false
# response = sendReceivePrompt(a, prompt, temperature=0.0)
# response = split(response, "<|im_end|>")[1]
# for (toolname, v) in a.tools
# if occursin(toolname, String(response))
# isusetool = true
# isuseplan = true
# break
# end
# end
# if length(a.memory[:shortterm]) != 0
# isusetool = true
# isuseplan = true
# end
# return isusetool
# return isuseplan
# end
@@ -1016,8 +1016,7 @@ function experience(dict::T) where {T<:AbstractDict}
end
function dictLatestStep(dict::T) where {T<:AbstractDict}
@show dict
function shortMemLatestStep(dict::T) where {T<:AbstractDict}
_latest_step = keys(dict)
_latest_step = [i for i in _latest_step]
_latest_step = _latest_step[end]