update
This commit is contained in:
@@ -455,10 +455,14 @@ function work(a::T, prompt::String) where {T<:agent}
|
||||
else
|
||||
# check for tool being called
|
||||
ActInd = findDetectedCharacter(headers, "Act:")[1]
|
||||
toolname = toolNameBeingCalled(chunkedtext[ActInd][:body], ) #WORKING
|
||||
toolname = toolNameBeingCalled(chunkedtext[ActInd][:body], a.tools) #WORKING
|
||||
toolinput = chunkedtext[ActInd+1][:body]
|
||||
|
||||
# function call
|
||||
if toolname == "chatbox"
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
|
||||
break
|
||||
@@ -666,7 +670,41 @@ function identifyUserIntention(a::T, usermsg::String) where {T<:agent}
|
||||
return answer
|
||||
end
|
||||
|
||||
|
||||
"""
|
||||
Send a msg to registered mqtt topic within mqttClient.
|
||||
|
||||
```jldoctest
|
||||
julia> using JSON3, UUIDs, Dates, FileIO, CommUtils, ChatAgent
|
||||
julia> mqttClientSpec = (
|
||||
clientName= "someclient", # name of this client
|
||||
clientID= "$(uuid4())",
|
||||
broker= "mqtt.yiem.ai",
|
||||
pubtopic= (imgAI="img/api/v0.0.1/gpu/request",
|
||||
txtAI="txt/api/v0.1.0/gpu/request"),
|
||||
subtopic= (imgAI="agent/api/v0.1.0/img/respond",
|
||||
txtAI="agent/api/v0.1.0/txt/respond"),
|
||||
keepalive= 30,
|
||||
)
|
||||
julia> msgMeta = Dict(
|
||||
:msgPurpose=> "updateStatus",
|
||||
:from=> "agent",
|
||||
:to=> "llmAI",
|
||||
:requestrespond=> "request",
|
||||
:sendto=> "", # destination topic
|
||||
:replyTo=> "agent/api/v0.1.0/txt/respond", # requester ask responder to send reply to this topic
|
||||
:repondToMsgId=> "", # responder is responding to this msg id
|
||||
:taskstatus=> "", # "complete", "fail", "waiting" or other status
|
||||
:timestamp=> Dates.now(),
|
||||
:msgId=> "$(uuid4())",
|
||||
)
|
||||
julia> newAgent = ChatAgent.agentReact(
|
||||
"Jene",
|
||||
mqttClientSpec,
|
||||
role=:assistant_react,
|
||||
msgMeta=msgMeta
|
||||
)
|
||||
```
|
||||
"""
|
||||
function sendReceivePrompt(a::T, prompt::String; timeout::Int=30) where {T<:agent}
|
||||
a.msgMeta[:msgId] = "$(uuid4())" # new msg id for each msg
|
||||
msg = Dict(
|
||||
@@ -702,11 +740,33 @@ function sendReceivePrompt(a::T, prompt::String; timeout::Int=30) where {T<:agen
|
||||
return result
|
||||
end
|
||||
|
||||
function toolNameBeingCalled(act::String, tools::Dict)
|
||||
"""
|
||||
Extract toolname from text.
|
||||
```jldoctest
|
||||
julia> text = " internetsearch\n"
|
||||
julia> tools = Dict(
|
||||
:internetsearch=>Dict(
|
||||
:name => "internetsearch",
|
||||
:description => "Useful for when you need to search the Internet",
|
||||
:input => "Input should be a search query.",
|
||||
:output => "",
|
||||
# :func => internetsearch # function
|
||||
),
|
||||
:chatbox=>Dict(
|
||||
:name => "chatbox",
|
||||
:description => "Useful for when you need to ask a customer what you need to know or to talk with them.",
|
||||
:input => "Input should be a conversation to customer.",
|
||||
:output => "" ,
|
||||
),
|
||||
)
|
||||
julia> toolname = toolNameBeingCalled(text, tools)
|
||||
```
|
||||
"""
|
||||
function toolNameBeingCalled(text::T, tools::Dict) where {T<:AbstractString}
|
||||
toolNameBeingCalled = nothing
|
||||
for (k, v) in tools
|
||||
toolname = String(k)
|
||||
if contains(act, toolname)
|
||||
if contains(text, toolname)
|
||||
toolNameBeingCalled = toolname
|
||||
break
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user