A machine that writes poems in the form of formal complaints to a fictional place, generated through a local language model, will create these poems using a fountain pen and a plotter. Once written, these poems will be given to the public
Github repository is found here
A local Large Language Model (LLM) called TheBloke Dolphin 2.1 'Mistral' 7B Q6_K hosted within LLM Studio using its OpenAI API Python interface to pass an API call to the LLM to generate responses for my code in llmapi.py.
Once the user presses the button 'Q' on the keyboard, the code generates a prompt based on a list of known prompts in the file 'llmapi/llm_messages'. Then, it randomly chooses a local authority within the file 'llmapi/councils', passes the pre-prompt and prompt to the LLM, and awaits the response.
Then the response is passed too the handwriting_synthesis https://github.com/otuva/handwriting-synthesis and that generates a tool path that is cleaned up in plot.py then is sent to the pen plotter plots on to paper via the axidraw api
Using GPT-4ALL, I have got a running LLM (Large Language Model) on a Dell PowerEdge server that will respond to a user from a prompt. It doesn't have a means of inputting information into the command at the moment.
Using a tool chain of Windows applications, I got a pen plotter to write a message if manually transferred with a Hershey's font message. The pen plotter is best used with a ballpoint tip; the end goal is to use a fountain pen.
The paper will need to be moved around the machine using PVC pipe rollers on skate board bearings mounted to wood, so that I can hack it together on a small budget while making it as simple to build as possible.
The PCB (Printed Circuit Board) is being designed in Tinkercad at https://www.tinkercad.com/things/dmjyJZViut4-brilliant-kieran-waasa/edit. It uses photo gates to detect the paper and an H-bridge to control motors with an Arduino Uno to control it all. The code can be found at ~/Code/photogate.
A folding machine will need to be bought from this guy and built.
Some minor suggestions for improvement:
m3 bolts whenever a bolt is needed for anything
m8 smooth rods when ever anything needs to rotate
skateboard bearings used for bearings
3d printed parts out of PLA when possible on a prusa Mk4
designed this controller for paper control via photo gates and dc motors controlled via bridge see pic
code for the photo gates is in ~/Code/photogate
note removed the 12V and the 5V grounds separate
H bridges are working now i have worked out you need twise the number of them to control 4 motors and working round a floating ground issue messing with the logic voltage.
current issue is trying to pull down the voltage on the photogates as they are not being pulled down and remain at logic level High
Here is the corrected text:
Using Daw.IO, I have started the flow diagram for the firmware. I have added error catching and photo gate control to the flow diagram and added an input for the user. Still, I don't know where to use servos or not - it depends on whether the paper comes out straight from the stack and if it needs stopping or not. I have left the flow chart at the plotter io state; the image is below. Still need to add this to hackaday.io.
I'm pleased to report progress with the flow chart, and I've created a diagram of the machine in its latest form. Notably, the motor that inserts the paper into the plotter never relinquishes control while it's being written on; instead, it uses a servo to change the path of the paper to a below-level location where the folding machine is housed.
using the code from this website https://microcontrollerslab.com/arduino-l293d-motor-driver-shield-tutorial/
and the pic of the test stand
I wrote some code to get the motors working using DeepSea to debug sections. The problem with the delay() in the loop stops anything below it from working, so all delays should be in functions.
I've got an if statement that will call the turnOnMotor() function if true, and will turn off the motors with its relevant function otherwise.
making a paper management mechanisms is taking too long so i will drop it
moved over to getting the code working and found that axi draw have an API fro there drawing program https://axidraw.com/doc/cli_api/ and im able to to use it to build it
got to the install via python3 -m pip install https://cdn.evilmadscientist.com/dl/ad/public/AxiDraw_API.zip
it conflicted need to come back later
/home/alex/Documents/Autocrat/AxiDraw_API_396/python3 axicli.py --help
re installed the openai lib via pip and now using pip3, it now all works
their should be a script that the user generates the prompt via adlib
so a box of of a location .
i have got the code to work file name is llmapi.py
now have the wizardllm uncensored and it works fine i can now generate the enquired text about what ever i like
tool chain so far
LLM manger -> Libra office template -> exsport as pdf -> pdf2svg to svg -> axidraw to gcode
for pdf to svg im going to be using https://github.com/dawbarton/pdf2svg with the tool chain of pdf2svg <input.pdf> <output.svg> [<page no of pdf or "all">]
pandoc could also work with pandoc input.txt -o output.pdf
after testing with the uncensored model i found a worrying issue, that's its horribly racist and is quick to insult people. the solution is too use prepared prompts that would be
minor issues
time too upload to github its getting hard to keep track of things on my laptop alone
I added it to my Git. I used the DeepSeek 7B model to help with making the UI, as I've not made anything with GUI before. After reading the code from the printer in the hackerspace, I chose to use the same library, Tkinter.
did some coding on the way home from the space and bashed out a GUI with the help of deep seek as I not used that library before and it works.
How this machine is going to be laid out with a track ball in the front of the monitor and the pen plotter too the side
edit: this is stupid i changed this
due to how much of an issue the GUI is I will remove it so can finish on time and will now randomly chose a prompt when the user presses a button on HID device
Possible to use an Uno as a HID (Human Interface Device) and have a micro-switch trigger a keyboard button. Maybe there's a HackDay article on the subject.
todo
both my CPP's for EMF camp have been accepted that is both this autocrat and the trebuchet
writing more functions
my code doesnt work i wrote a lot of functions so will come back tomorrow and re do it
wrote more code to get it to output into a .md file however this is all on one line a porblem for later
now time to get it talking to pandoc its having a hissy fit using this command pandoc -f markdown output.md -t test.pdf
fixed the output of the message and fixed the /n with a replace
code works to produce pdf file now need to format the file to look like a letter using LaTex
built the pen plotter and got it plotting
its API documentation here https://wiki.evilmadscientist.com/AxiDraw
added a arm to hold down paper its 3d printed
debugging the pen plotter as their was some issues with voltage on the stepper drivers as so upped them to 0.8v over 0.5v this solved the issue
updated the board to work with a the home Gcode now its orgin is in the top left of the machine
code is being started to be made on the automatic plotting of the markdown with the plot.py file
added files to make svg and try and convert them this can be found in the history of chatgpt and the
files
https://github.com/sjvasquez/handwriting-synthesis
this was used by stuff made here to great affect it should solve both the hand writing issue and taking the text and converting into something that the pen plotter can use
https://github.com/sjvasquez/handwriting-synthesis needs tensor flow and as i dont have a gpu in the server i wil be needing it to be done using cpu so that means building from source YAY/s
export CUDA_VISIBLE_DEVICES=""
updated the git to this new repo https://github.com/otuva/handwriting-synthesis
to get the genration working you need to get it to running in a enviroment
(hand_gen_env) alex@henry:~/Documents/Autocrat/handwriting-synthesis$ python3 -m venv hand_gen_env
(hand_gen_env) alex@henry:~/Documents/Autocrat/handwriting-synthesis$ python main.py
got the axi draw working on the server i needs a regex from the
height="100%" to height="1052.362179" and width="100%" to width="744.09447"
the pen plotter chrashes now this is good fun/s
good idea is to try and realses the internal of the pen plotter and try again
the above code works btw and now need to get it working for my project
things too do
Things I have done today,
I have managed to get the handwriting recognition model working, and it is now installed into my code with the output of the LLM Bing piped into the input of the model. Additionally, I have added a plot.py file for testing the plotter as it was having issues with reliability; this was resolved by reflowing the USB port on the PCB and changing out the cable.
fixed the code that sorts the lines into 75 char long and now outputs a short poem this is a good idea as its speeds things up
problem is that it still draws the box the issue is that the <ns0:defs /><ns0:rect height="1052.362179" width="744.09447" x="0" y="0" /> is making a black sqaure that the plotter plots and its an issue alos having stability issues with the code
the git has also gone missing so need to repair that
an idea is too whole sale replacemnt of top of the svg and get the correct one from the bottom axi draw api
used a hacky fix to make sure the svg is valid by chopping off the top and adding valid svg headers from a known file.
trimmed in the plotter as it was having issues with one side being a little too high
code now works after i spent so long trying to get it to work this has taken a long time
so far I have
the pen plotter needs to be reliable so to test the pen it can do something useful as well, m
finally i can say it is all in one piece ( minus the servo board that broke )
with the screen off
making the posters off the .GOV website the whole project is ment to be piss take so why not the branding too
so i present the new logo of the Autocrat
in publisher writing the how to poster
a promo poster is going to be next to the machine showing how it was made this was also made in publisher
Now the replacement EBB board arrived I can now finish the project. so lets go over what I did