update
This commit is contained in:
60
src/type.jl
60
src/type.jl
@@ -80,7 +80,7 @@ abstract type agent end
|
||||
# Ref: Chat prompt format https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/discussions/3
|
||||
# messages= [Dict(:role=>"system", :content=> "", :timestamp=> Dates.now()),]
|
||||
chathistory = Vector{Dict{Symbol, Any}}() # store messages history in the format :name=>"message"
|
||||
maxUserMsg::Int = 10 # 31th and earlier messages will get summarized
|
||||
maxHistoryMsg::Int = 20 # 31th and earlier messages will get summarized
|
||||
keywordinfo = Dict{Symbol, Any}(
|
||||
:userinfo => Dict{Symbol, Any}(),
|
||||
:retailerinfo => Dict{Symbol, Any}(),
|
||||
@@ -119,7 +119,7 @@ function sommelier(
|
||||
:text2text=>Dict(
|
||||
:mqtttopic=> "txt2text/api/v1/prompt/gpu",
|
||||
),
|
||||
),
|
||||
)
|
||||
;
|
||||
name::String="Assistant",
|
||||
id::String=string(uuid4()),
|
||||
@@ -131,29 +131,8 @@ function sommelier(
|
||||
:output => "" ,
|
||||
:func => nothing,
|
||||
),
|
||||
# :wikisearch=>Dict(
|
||||
# :name => "wikisearch",
|
||||
# :description => "Useful for when you need to search an encyclopedia",
|
||||
# :input => "Input is keywords and not a question.",
|
||||
# :output => "",
|
||||
# :func => wikisearch, # put function here
|
||||
# ),
|
||||
# :wineStock=>Dict(
|
||||
# :name => "wineStock",
|
||||
# :description => "useful for when you need to search for wine by your description, price, name or ID.",
|
||||
# :input => "Input should be a search query with as much details as possible.",
|
||||
# :output => "" ,
|
||||
# :func => nothing,
|
||||
# ),
|
||||
# :NTHING=>Dict(
|
||||
# :name => "NTHING",
|
||||
# :description => "useful for when you don't need to use tools or actions",
|
||||
# :input => "No input is needed",
|
||||
# :output => "" ,
|
||||
# :func => nothing,
|
||||
# ),
|
||||
),
|
||||
maxUserMsg::Int=20,
|
||||
maxHistoryMsg::Int=20,
|
||||
)
|
||||
|
||||
#NEXTVERSION publish to a.config[:configtopic] to get a config.
|
||||
@@ -166,23 +145,38 @@ function sommelier(
|
||||
config = config,
|
||||
mqttClient = mqttClient,
|
||||
msgMeta = msgMeta,
|
||||
maxUserMsg = maxUserMsg,
|
||||
maxHistoryMsg = maxHistoryMsg,
|
||||
tools = tools,
|
||||
attemptlimit = 5,
|
||||
attemptcount = 0,
|
||||
)
|
||||
|
||||
|
||||
return newAgent
|
||||
end
|
||||
|
||||
|
||||
|
||||
function initAgentMemory(a::T) where {T<:agent}
|
||||
a.chathistory = Dict{String,Any}()
|
||||
a.mctstree = Dict{Symbol, Any}()
|
||||
a.plan[:activeplan] = Dict{Symbol, Any}()
|
||||
a.plan[:currenttrajectory] = Dict{Symbol, Any}()
|
||||
# function initAgentMemory(a::T) where {T<:agent}
|
||||
# a.chathistory = Dict{String,Any}()
|
||||
# a.mctstree = Dict{Symbol, Any}()
|
||||
# a.plan[:activeplan] = Dict{Symbol, Any}()
|
||||
# a.plan[:currenttrajectory] = Dict{Symbol, Any}()
|
||||
# end
|
||||
|
||||
|
||||
function clearMessage(a::T) where {T<:agent}
|
||||
for i in eachindex(a.messages)
|
||||
if length(a.messages) > 0
|
||||
pop!(a.messages)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
a.memory = newAgentMemory()
|
||||
|
||||
# @show a.messages
|
||||
# @show a.memory
|
||||
end
|
||||
|
||||
|
||||
@@ -239,10 +233,6 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user