update
This commit is contained in:
29
src/utils.jl
29
src/utils.jl
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user