update newAgent
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
julia_version = "1.9.3"
|
||||
manifest_format = "2.0"
|
||||
project_hash = "1af8dd5b4b143461cea0c3d78c642fd87183b648"
|
||||
project_hash = "7efd6278ecd5d8f7282ac1aecdb67514b8cb0b8b"
|
||||
|
||||
[[deps.ArgTools]]
|
||||
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
|
||||
@@ -14,6 +14,12 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
|
||||
[[deps.Base64]]
|
||||
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||
|
||||
[[deps.CommUtils]]
|
||||
deps = ["Dates", "JSON3", "Mosquitto", "Redis", "UUIDs"]
|
||||
path = "/root/.julia/dev/CommUtils"
|
||||
uuid = "646cbe82-3d4a-47b2-9440-2e80a472ca20"
|
||||
version = "0.1.0"
|
||||
|
||||
[[deps.Compat]]
|
||||
deps = ["UUIDs"]
|
||||
git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c"
|
||||
@@ -141,6 +147,12 @@ version = "0.1.14"
|
||||
[[deps.Mmap]]
|
||||
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
|
||||
|
||||
[[deps.Mosquitto]]
|
||||
deps = ["Libdl", "Random", "Test"]
|
||||
path = "/root/.julia/dev/Mosquitto"
|
||||
uuid = "db317de6-444b-4dfa-9d0e-fbf3d8dd78ea"
|
||||
version = "0.4.1"
|
||||
|
||||
[[deps.MozillaCACerts_jll]]
|
||||
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
|
||||
version = "2022.10.11"
|
||||
@@ -206,6 +218,12 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
|
||||
deps = ["SHA", "Serialization"]
|
||||
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
|
||||
[[deps.Redis]]
|
||||
deps = ["DataStructures", "Dates", "Sockets"]
|
||||
git-tree-sha1 = "6b3c136222b08ae0c71657f2501c6741782a1ad1"
|
||||
uuid = "0cf705f9-a9e2-50d1-a699-2b372a39b750"
|
||||
version = "1.0.0"
|
||||
|
||||
[[deps.Requires]]
|
||||
deps = ["UUIDs"]
|
||||
git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
|
||||
|
||||
@@ -4,8 +4,10 @@ authors = ["narawat <narawat@gmail.com>"]
|
||||
version = "0.1.0"
|
||||
|
||||
[deps]
|
||||
CommUtils = "646cbe82-3d4a-47b2-9440-2e80a472ca20"
|
||||
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
|
||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
||||
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
|
||||
Mosquitto = "db317de6-444b-4dfa-9d0e-fbf3d8dd78ea"
|
||||
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
|
||||
|
||||
@@ -4,7 +4,8 @@ module interface
|
||||
export agent, addNewMessage, clearMessage, removeLatestMsg, generatePrompt_tokenPrefix,
|
||||
generatePrompt_tokenSuffix
|
||||
|
||||
using JSON3, DataStructures, Dates
|
||||
using JSON3, DataStructures, Dates, UUIDs
|
||||
using CommUtils
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# pythoncall setting #
|
||||
@@ -18,16 +19,16 @@ using JSON3, DataStructures, Dates
|
||||
# systemPython = split(read(`which python`, String), "\n")[1]
|
||||
# ENV["JULIA_PYTHONCALL_EXE"] = systemPython # find python location with $> which python ex. raw"/root/conda/bin/python"
|
||||
|
||||
using PythonCall
|
||||
const py_agents = PythonCall.pynew()
|
||||
const py_llms = PythonCall.pynew()
|
||||
function __init__()
|
||||
# PythonCall.pycopy!(py_cv2, pyimport("cv2"))
|
||||
# using PythonCall
|
||||
# const py_agents = PythonCall.pynew()
|
||||
# const py_llms = PythonCall.pynew()
|
||||
# function __init__()
|
||||
# # PythonCall.pycopy!(py_cv2, pyimport("cv2"))
|
||||
|
||||
# equivalent to from urllib.request import urlopen in python
|
||||
PythonCall.pycopy!(py_agents, pyimport("langchain.agents"))
|
||||
PythonCall.pycopy!(py_llms, pyimport("langchain.llms"))
|
||||
end
|
||||
# # equivalent to from urllib.request import urlopen in python
|
||||
# PythonCall.pycopy!(py_agents, pyimport("langchain.agents"))
|
||||
# PythonCall.pycopy!(py_llms, pyimport("langchain.llms"))
|
||||
# end
|
||||
|
||||
#------------------------------------------------------------------------------------------------100
|
||||
|
||||
@@ -35,11 +36,11 @@ end
|
||||
|
||||
@kwdef mutable struct agent
|
||||
availableRole=["system", "user", "assistant"]
|
||||
agentName="assistant"
|
||||
agentName::String="assistant"
|
||||
maxUserMsg::Int= 10
|
||||
llmAIRequestMqttTopic_openblas= "llm/openblas/request"
|
||||
llmAIRequestMqttTopic_gpu= "llm/api/v0.0.1/gpu/request"
|
||||
self_llmReceiveMqttTopic= "chatbothub/llm/respond"
|
||||
earlierConversation::String="" # summary of earlier conversation
|
||||
thoughts::String= "" # internal thinking area
|
||||
mqttClient::Union{mqttClient, Nothing}= nothing
|
||||
|
||||
""" Dict(Role=> Content) ; Role can be system, user, assistant
|
||||
Example:
|
||||
@@ -56,20 +57,16 @@ end
|
||||
function agent(
|
||||
agentName::String,
|
||||
systemMessage::String, # system message of an agent
|
||||
llmAIRequestMqttTopic_openblas::String,
|
||||
llmAIRequestMqttTopic_gpu::String,
|
||||
self_llmReceiveMqttTopic::String;
|
||||
availableRole::AbstractArray=["system", "user", "assistant"],
|
||||
maxUserMsg::Int=10)
|
||||
maxUserMsg::Int=10,
|
||||
mqttClientSpec::Tuple;
|
||||
availableRole::AbstractArray=["system", "user", "assistant"],)
|
||||
|
||||
newAgent= agent()
|
||||
newAgent.llmAIRequestMqttTopic_openblas= llmAIRequestMqttTopic_openblas
|
||||
newAgent.llmAIRequestMqttTopic_gpu= llmAIRequestMqttTopic_gpu
|
||||
newAgent.self_llmReceiveMqttTopic= self_llmReceiveMqttTopic
|
||||
newAgent.availableRole= availableRole
|
||||
newAgent.maxUserMsg= maxUserMsg
|
||||
systemMessage= "Your name is $agentName. " * systemMessage
|
||||
newAgent.messages= [Dict(:role=>"system", :content=> systemMessage, :timestamp=> Dates.now()),]
|
||||
newAgent.mqttClient= mqttClient(mqttClientSpec)
|
||||
|
||||
return newAgent
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user