This commit is contained in:
narawat lamaiin
2024-05-05 12:06:32 +07:00
parent 1ac2ad1801
commit 77b590c6ad
4 changed files with 78 additions and 128 deletions

View File

@@ -12,80 +12,76 @@ abstract type agent end
""" A sommelier agent.
Arguments\n
-----
mqttClient::Client
MQTTClient's client
msgMeta::Dict{Symbol, Any}
A dict contain info about a message.
config::Dict{Symbol, Any}
Config info for an agent. Contain mqtt topic for internal use and other info.
Keyword Arguments\n
-----
name::String
Agent's name
id::String
Agent's ID
tools::Dict{Symbol, Any}
Agent's tools
maxHistoryMsg::Integer
max history message
# Arguments
- `mqttClient::Client`
MQTTClient's client
- `msgMeta::Dict{Symbol, Any}`
A dict contain info about a message.
- `config::Dict{Symbol, Any}`
Config info for an agent. Contain mqtt topic for internal use and other info.
# Keyword Arguments
- `name::String`
Agent's name
- `id::String`
Agent's ID
- `tools::Dict{Symbol, Any}`
Agent's tools
- `maxHistoryMsg::Integer`
max history message
Return\n
-----
nothing
# Return
- `nothing`
Example:
```jldoctest
julia> using YiemAgent, MQTTClient, GeneralUtils
julia> msgMeta = GeneralUtils.generate_msgMeta(
"N/A",
replyTopic = "/testtopic/prompt"
)
julia> tools= Dict(
:chatbox=>Dict(
:name => "chatbox",
:description => "Useful only for when you need to ask the user for more info or context. Do not ask the user their own question.",
:input => "Input should be a text.",
:output => "" ,
:func => nothing,
),
)
julia> agentConfig = Dict(
:receiveprompt=>Dict(
:mqtttopic=> "/testtopic/prompt", # topic to receive prompt i.e. frontend send msg to this topic
),
:receiveinternal=>Dict(
:mqtttopic=> "/testtopic/internal", # receive topic for model's internal
),
:text2text=>Dict(
:mqtttopic=> "/text2text/receive",
),
)
julia> client, connection = MakeConnection("test.mosquitto.org", 1883)
julia> agent = YiemAgent.bsommelier(
client,
msgMeta,
agentConfig,
name= "assistant",
id= "555", # agent instance id
tools=tools,
)
```
# Example
```jldoctest
julia> using YiemAgent, MQTTClient, GeneralUtils
julia> msgMeta = GeneralUtils.generate_msgMeta(
"N/A",
replyTopic = "/testtopic/prompt"
)
julia> tools= Dict(
:chatbox=>Dict(
:name => "chatbox",
:description => "Useful only for when you need to ask the user for more info or context. Do not ask the user their own question.",
:input => "Input should be a text.",
:output => "" ,
:func => nothing,
),
)
julia> agentConfig = Dict(
:receiveprompt=>Dict(
:mqtttopic=> "/testtopic/prompt", # topic to receive prompt i.e. frontend send msg to this topic
),
:receiveinternal=>Dict(
:mqtttopic=> "/testtopic/internal", # receive topic for model's internal
),
:text2text=>Dict(
:mqtttopic=> "/text2text/receive",
),
)
julia> client, connection = MakeConnection("test.mosquitto.org", 1883)
julia> agent = YiemAgent.bsommelier(
client,
msgMeta,
agentConfig,
name= "assistant",
id= "555", # agent instance id
tools=tools,
)
```
# TODO
- [WORKING] update docstring
- [x] implement the function
# TODO
- [] update docstring
- [x] implement the function
Signature\n
-----
# Signature
"""
@kwdef mutable struct sommelier <: agent
name::String
id::String
config::Dict
tools::Dict
name::String # agent name
id::String # agent id
config::Dict # agent config
tools::Dict
thinkinglimit::Integer # thinking round limit
thinkingcount::Integer # used to count attempted round of a task