# frozen_string_literal: true LLAMA_PATH = "#{Dir.home}/Downloads/Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile" PROMPT = <<~END_OF_PROMPT poem: If you can't write poems, write me poem: IN THE SPRING MY LUNGS STILL SOMEHOW EXPAND. poem: A MAN ONCE MAILED ME A PIECE OF HIS HEART poem: THIS AMULET AT ANY PRICE FELT LIKE THE TRUTH poem: this amulet is a simple token which proves my love's truth poem: sphinx of black quartz, judge my vow poem: DON'T WORRY. poem: in the early hours of the new year i lie on my back waiting. poem: All my life I had this image of what a poet should be poem: Winter evening, a leaf, a blue sky above. poem: Lethargically good. poem: END_OF_PROMPT .strip def doit! r, w = IO.pipe spawn("#{LLAMA_PATH} --no-display-prompt --gpu APPLE -n 128 -p \"#{PROMPT}\"", out: w, err: '/dev/null') spawn('ruby extract_poems.rb', in: r) Process.wait # just in case r.close w.close end loop { doit! }