This commit is contained in:
narawat lamaiin
2024-04-18 13:27:29 +07:00
parent 4415bdbe91
commit 2f5800348f
2 changed files with 109 additions and 81 deletions

View File

@@ -76,7 +76,7 @@ abstract type agent end
Signature\n
-----
""" #TODO update document
""" #TODO update docstring
@kwdef mutable struct sommelier <: agent
name::String
id::String
@@ -113,39 +113,41 @@ abstract type agent end
msgMeta::Dict{Symbol, Any} # a template for msgMeta
# put incoming message here. waiting for further processing
incomingUserMsg::Channel{Dict} = Channel{Dict}(8) # for user communication
internalMsg::Channel{Dict} = Channel{Dict}(8) # for internal communication
receiveUserMsgChannel::Channel{Dict} = Channel{Dict}(8) # for incoming user communication
receiveInternalMsgChannel::Channel{Dict} = Channel{Dict}(8) # for internal communication
end
function sommelier(
mqttClient,
msgMeta::Dict= GeneralUtils.generate_msgMeta("N/A"),
config::Dict = Dict(
:frontend=> Dict(
:mqtttopic=> nothing
receiveUserMsgChannel::Channel,
receiveInternalMsgChannel::Channel,
mqttClient,
msgMeta::Dict= GeneralUtils.generate_msgMeta("N/A"),
config::Dict = Dict(
:frontend=> Dict(
:mqtttopic=> nothing
),
:internal=> Dict(
:mqtttopic=> nothing
),
:text2text=> Dict(
:mqtttopic=> "txt2text/api/v1/prompt/gpu",
),
)
;
name::String= "Assistant",
id::String= string(uuid4()),
tools::Dict= Dict(
:chatbox=> Dict(
:name => "chatbox",
:description => "Useful for when you need to communicate with the user.",
:input => "Input should be a conversation to the user.",
:output => "" ,
:func => nothing,
),
),
:internal=> Dict(
:mqtttopic=> nothing
),
:text2text=> Dict(
:mqtttopic=> "txt2text/api/v1/prompt/gpu",
),
)
;
name::String= "Assistant",
id::String= string(uuid4()),
tools::Dict= Dict(
:chatbox=> Dict(
:name => "chatbox",
:description => "Useful for when you need to communicate with the user.",
:input => "Input should be a conversation to the user.",
:output => "" ,
:func => nothing,
),
),
maxHistoryMsg::Integer= 20,
thinkinglimit::Integer= 5,
thinkingcount::Integer= 0,
maxHistoryMsg::Integer= 20,
thinkinglimit::Integer= 5,
thinkingcount::Integer= 0,
)
#NEXTVERSION publish to a.config[:configtopic] to get a config.
@@ -153,15 +155,17 @@ function sommelier(
#NEXTVERSION set agent according to config
newAgent = sommelier(
name = name,
id = id,
config = config,
mqttClient = mqttClient,
msgMeta = msgMeta,
maxHistoryMsg = maxHistoryMsg,
tools = tools,
thinkinglimit = thinkinglimit,
thinkingcount = thinkingcount,
receiveUserMsgChannel= receiveUserMsgChannel,
receiveInternalMsgChannel= receiveInternalMsgChannel,
name= name,
id= id,
config= config,
mqttClient= mqttClient,
msgMeta= msgMeta,
maxHistoryMsg= maxHistoryMsg,
tools= tools,
thinkinglimit= thinkinglimit,
thinkingcount= thinkingcount,
)
return newAgent