Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- model="llama-3.2-3b-instruct"
- #Gender is a 50/50. No need for an LLM there.
- gender=$([ $((RANDOM % 2)) -eq 0 ] && echo "Male" || echo "Female")
- #Ancestry; Trying for a high variation here.
- ancestry=$(curl -s http://localhost:9090/v1/chat/completions -H "Content-Type: application/json" -d '{
- "model": "${model}",
- "messages": [
- { "role": "system", "content": "You are a character generator. You give the shortest possible answer you can." },
- { "role": "user", "content": "Pick a random ancestry for the human character. It can be any regular Earth ancestry. Pick anywhere from the planet." }
- ],
- "temperature": 10,
- "max_tokens": -1,
- "stream": false
- }' | jq '.choices[].message.content' | sed -e 's/ \\n"//g' | tr -cd '[:alnum:][:space:]' )
- #Last Name; We feed ancestry and gender here so the last name should be less random.
- lastn=$(curl -s http://localhost:9090/v1/chat/completions -H "Content-Type: application/json" -d "{
- \"model\": \"${model}\",
- \"messages\": [
- { \"role\": \"system\", \"content\": \"You are a character generator. You give the shortest possible answer you can.\" },
- { \"role\": \"user\", \"content\": \"Give the last name of a ${ancestry}, ${gender} character.\" }
- ],
- \"temperature\": 0.8,
- \"max_tokens\": -1,
- \"stream\": false
- }" | jq '.choices[].message.content' | sed -e 's/ \\n//g' | tr -cd '[:alnum:][:space:]' )
- #First name. Narrowing down what the LLM thinks the first name should be now that we know the ancestry, gender and last name.
- firstn=$(curl -s http://localhost:9090/v1/chat/completions -H "Content-Type: application/json" -d "{
- \"model\": \"${model}\",
- \"messages\": [
- { \"role\": \"system\", \"content\": \"You are a character generator. You give the shortest possible answer you can.\" },
- { \"role\": \"user\", \"content\": \"Give the first name of a ${ancestry}, ${gender} character with the ${lastn} surname.\" }
- ],
- \"temperature\": 0.8,
- \"max_tokens\": -1,
- \"stream\": false
- }" | jq '.choices[].message.content' | sed -e 's/ \\n//g' | tr -cd '[:alnum:][:space:]' )
- occu=$(curl -s http://localhost:9090/v1/chat/completions -H "Content-Type: application/json" -d "{
- \"model\": \"${model}\",
- \"messages\": [
- { \"role\": \"system\", \"content\": \"You are a character generator. You give the shortest answer possible.\" },
- { \"role\": \"user\", \"content\": \"Give the modern occupation of ${firstn} ${lastn}, a ${gender} of ${ancestry} ancestry.\" }
- ],
- \"temperature\": 1.8,
- \"max_tokens\": -1,
- \"stream\": false
- }" | jq '.choices[].message.content' | sed -e 's/ \\n//g' | tr -cd '[:alnum:][:space:]' )
- hair=$(curl -s http://localhost:9090/v1/chat/completions -H "Content-Type: application/json" -d "{
- \"model\": \"${model}\",
- \"messages\": [
- { \"role\": \"system\", \"content\": \"You are a character generator. You give the shortest answer possible.\" },
- { \"role\": \"user\", \"content\": \"We are considering ${firstn} ${lastn}, a ${gender} of ${ancestry} ancestry. Their occupation is ${occu}. What should their hair color be?\" }
- ],
- \"temperature\": 1.8,
- \"max_tokens\": -1,
- \"stream\": false
- }" | jq '.choices[].message.content' | sed -e 's/ \\n//g' | tr -cd '[:alnum:][:space:]' )
- echo "${ancestry}, ${gender}, ${firstn}, ${lastn}, ${occu}, ${hair} hair."
- curl -s http://localhost:9090/v1/chat/completions -H "Content-Type: application/json" -d "{
- \"model\": \"${model}\",
- \"messages\": [
- { \"role\": \"system\", \"content\": \"You are a character generator. You give the shortest answer possible.\" },
- { \"role\": \"user\", \"content\": \"We are considering ${firstn} ${lastn}, a ${gender} of ${ancestry} ancestry. Their occupation is ${occu}. Their hair color is ${hair}. Write a DALL-E description of them.\" }
- ],
- \"temperature\": 1.8,
- \"max_tokens\": -1,
- \"stream\": false
- }" | jq '.choices[].message.content'
Advertisement
Add Comment
Please, Sign In to add comment