diff --git a/codesnippet/nats.jl b/codesnippet/nats.jl new file mode 100644 index 0000000..26968f6 --- /dev/null +++ b/codesnippet/nats.jl @@ -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)) + + + + +