update
This commit is contained in:
79
codesnippet/nats.jl
Normal file
79
codesnippet/nats.jl
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
using NATS, JSON3
|
||||||
|
connection = NATS.connect("nats.yiem.cc:4222")
|
||||||
|
sub1 = NATS.reply(connection, "some_subject"; queue_group="group1") do msg
|
||||||
|
payload = JSON3.read(msg.payload)
|
||||||
|
println(payload)
|
||||||
|
println(msg.reply_to)
|
||||||
|
# publish(connection, msg.reply_to, "ACK")
|
||||||
|
return JSON3.write(Dict(:a=>"wassup"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using NATS, JSON3, GeneralUtils
|
||||||
|
connection = NATS.connect("nats.yiem.cc:4222")
|
||||||
|
|
||||||
|
msgMeta = GeneralUtils.generate_msgMeta(
|
||||||
|
"text2textinstruct_medium.inference.api.v1";
|
||||||
|
msgPurpose= "inference",
|
||||||
|
senderName= "yiemagent",
|
||||||
|
senderId= GeneralUtils.uuid4snakecase(),
|
||||||
|
receiverName= "text2textinstruct",
|
||||||
|
)
|
||||||
|
|
||||||
|
llmHttpTimeout = 60
|
||||||
|
outgoingMsg = Dict(
|
||||||
|
:msgMeta=> msgMeta,
|
||||||
|
:payload=> Dict(
|
||||||
|
:text=> "Wassup buddy!",
|
||||||
|
:kwargs=> Dict(
|
||||||
|
:max_tokens=> 2048,
|
||||||
|
:stop=> ["<|im_end|>"],
|
||||||
|
:temperature=> 0.2,
|
||||||
|
),
|
||||||
|
:llmHttpTimeout=>llmHttpTimeout,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
r = NATS.request(String, connection, "text2textinstruct_medium.inference.api.v1",
|
||||||
|
JSON3.write(outgoingMsg); timer=Timer(llmHttpTimeout))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using NATS, JSON3, GeneralUtils
|
||||||
|
connection = NATS.connect("nats.yiem.cc:4222")
|
||||||
|
|
||||||
|
msgMeta = GeneralUtils.generate_msgMeta(
|
||||||
|
"tonpc.containerServices",
|
||||||
|
msgPurpose="reset container",
|
||||||
|
senderName= "",
|
||||||
|
)
|
||||||
|
|
||||||
|
outgoingMsg = Dict(
|
||||||
|
:msgMeta=> msgMeta,
|
||||||
|
:payload=> "docker container restart ollama-instance-2",
|
||||||
|
)
|
||||||
|
|
||||||
|
# may be I can't use NATS request inside NATS reply??
|
||||||
|
_ = NATS.request(String, connection, msgMeta[:sendTopic], JSON3.write(outgoingMsg); timer=Timer(10))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user