I see this subject comes up frequently.
I deviated from the LM317 because of the issues mentioned here already.
* both the TO-220 and the TO-92 version have a limit as to the minimum current they can be throttled down to.
* both cannot take more than 40V (not needed here)
A slightly more complex version of a current limiter is the Constant-Current-Two-Pole. It is made out of ubiquitous components.
https://www.elektronik-kompendium.de/public/schaerer/curr2pol.htmYou would probably need to employ a translator program.
It can be used as a current source or sink - hence the term "two-pole".
You can set any small current you like with unbeaten stability and use it with voltages up to several hundred volts if you like.
Use BD139/140 or similar for up to 80 Volts.