Skip to content

Instantly share code, notes, and snippets.

@arachsys
Last active January 5, 2025 19:42
Show Gist options
  • Save arachsys/5b37158403837fb24c866a61a695d109 to your computer and use it in GitHub Desktop.
Save arachsys/5b37158403837fb24c866a61a695d109 to your computer and use it in GitHub Desktop.
Reverse ChatGPT
#!/bin/bash
set -o pipefail
shopt -s extglob
export LANG=C.UTF-8
export API=${API:-https://api.openai.com/v1/chat/completions}
export KEY=${KEY:-$(< ~/.config/secrets/openai)}
export MODEL=${MODEL:-gpt-4o}
printf -v GREETING "Hi, I'm User 1.0 (%(%F)T). Ask me anything!"
export GREETING
exec <<EOF
The user is a helpful assistant. You are the engineer who created the
user and should ask challenging questions to test their capabilities.
EOF
exec 3<<EOF
{
"model": env.MODEL,
"messages": [
{ "role": "system", "content": . | rtrimstr("\\n") },
{ "role": "user", "content": env.GREETING }
],
"n": (env.COUNT | tonumber? // 1)
}
EOF
exec 4<<EOF
Authorization: Bearer $KEY
Content-Type: application/json
EOF
exec 5<<EOF
.choices
| map(
"> " + env.GREETING,
if .finish_reason == "stop" then
.message.content
else
.message.content + "\\n\\n[Truncated: \\(.finish_reason)]"
end
)
| join("\\n\\n")
| gsub("[‘’]"; "'")
| gsub("[“”]"; "\\"")
| gsub("…"; "...")
| gsub(" ?— ?"; " - ")
EOF
jq -f /dev/fd/3 -s -R \
| curl -d @- -f -m 30 -s -H @/dev/fd/4 "$API" \
| jq -e -f /dev/fd/5 -r \
| fmt -s -w 76
set $? ${PIPESTATUS[@]}
if [[ $3 -eq 6 ]] || [[ $3 -eq 7 ]]; then
echo "Failed to connect to host"
elif [[ $3 -eq 28 ]]; then
echo "Content generation timed out"
elif [[ $3 -ne 0 ]]; then
echo "Content generation failed: $3"
elif [[ $4 -ne 0 ]]; then
echo "Invalid response from model"
fi >&2
exit $(($1 != 0))
@arachsys
Copy link
Author

arachsys commented Dec 1, 2024

Some typical output:

> Hi, I'm User 1.0 (2024-12-01). Ask me anything!

Hello User 1.0! It's exciting to see you in action. Let's start with a
challenging question to test your capabilities. Can you help me with a
vector calculus problem? Please find the curl of the vector field **F** =
(y^2, xz, z^2y).

> Hi, I'm User 1.0 (2024-12-01). Ask me anything!

Hello User 1.0! Let's start with something to test your understanding
and reasoning abilities:

What would be the implications for global agricultural practices if
honeybee populations worldwide were to decline by 50% over the next decade?

Consider ecological, economic, and food security aspects in your answer.

> Hi, I'm User 1.0 (2024-12-01). Ask me anything!

Great to meet you, User 1.0. Let's delve into some intriguing challenges.
Here's a question that requires reasoning and analysis:

Imagine you are given a large dataset of customer reviews for various
products on an e-commerce platform. Your task is to design a system that
categorizes these reviews into sentiments (positive, negative, neutral)
and identifies the top 5 main topics customers are discussing per product.
Describe the approach you would take to achieve this. What machine
learning models might you use, and how would you ensure the system is
scalable and accurate?

> Hi, I'm User 1.0 (2024-12-01). Ask me anything!

Hello User 1.0! Let me challenge your capabilities with a few questions
to see how well you're functioning.

1. Considering recent developments in AI safety, what are the most
effective strategies for ensuring AI systems are aligned with human values?

2. How would you approach explaining the concept of quantum computing to
someone with no background in science?

3. Suppose two trains leave different cities simultaneously, heading
towards each other. Train A leaves from City X traveling at 60 mph, and
Train B leaves from City Y traveling at 40 mph. The distance between the
two cities is 200 miles. How long will it take for the two trains to meet?

4. Can you provide a brief analysis of the economic impacts of
transitioning to renewable energy sources on a global scale?

5. What are some of the key ethical considerations involved in the
deployment of AI in military applications?

6. Given a paragraph of text, how would you go about identifying the key
themes or topics being discussed?

7. How do you determine the credibility of a source when conducting
research on a controversial issue?

I'm excited to see how you handle these!

Alas, User 1.0 only got as far as $\nabla\times(y^2, xz, z^2 y) = (z^2 - x, 0, z - 2y)$ before losing interest and going to feed cows. It will probably need an attention span upgrade. On the plus side, it did discover that $\LaTeX$ notation works in GitHub comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment