amulets/poem_loop.rb

52 lines
992 B
Ruby
Raw Normal View History

2024-11-14 00:31:51 -05:00
# 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
2024-11-14 00:32:20 -05:00
loop { doit! }