pantry/projects/github.com/AntonOsika/gpt-engineer/entrypoint.sh
Jacob Heider cdebf5af62
Revert "update(gpt-engineer)[2]"
This reverts commit 399a67e162.

Revert "update(gpt-engineer)[1]"

This reverts commit a38f5f1973.

Revert "update(gpt-engineer)"

This reverts commit ef47d55b43.
2023-10-10 14:44:37 -04:00

65 lines
1.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env -S tea bash
#---
# dependencies:
# charm.sh/gum: '*'
#---
set -eo pipefail
# attempt to get the key from the users shell rc files (if set)
if [ -z "$OPENAI_API_KEY" -a -n "$SHELL" ]; then
export OPENAI_API_KEY="$(env -i "$SHELL" -ic 'echo $OPENAI_API_KEY')"
fi
if [ -z "$OPENAI_API_KEY"]; then
gum format <<EoMD
# OpenAI API key required
You need an OpenAI API key to use this package.
> https://platform.openai.com/account/api-keys
GPT4 is recommended (but you gotta sign up for the
the [waitlist](https://openai.com/waitlist/gpt-4-api))
**this key will not be persisted by tea!**
EoMD
echo # spacer
export OPENAI_API_KEY="$(gum input --placeholder 'key pls')"
fi
gum format <<EoMD
# what do you want to build?
the example prompt \`gpt-engineer\` provide is:
> we are writing snake in python. MVC components split in separate files. keyboard control.
type your prompt below (⌃D when done)
EoMD
echo #spacer
prompt="$(gum write --placeholder 'main prompt…')"
gum format <<EoMD
# we store the results in your documents folder, whats the title?
EoMD
title="$(gum input --placeholder 'title?')"
docs="${XDG_DOCUMENTS_DIR:-$HOME/Documents}/GPT Engineer"
mkdir -p "$docs/$title"
echo "$prompt" > "$docs/$title/main_prompt"
gum format <<EoMD
> output will be written to \`$docs/$title\`
# running \`gpt-engineer\`
EoMD
exec gpt-engineer "$docs/$title"