Created
October 14, 2024 07:40
-
-
Save ericzakariasson/c4f06bb9c54dad2845695da56abc2da2 to your computer and use it in GitHub Desktop.
Small script to answer the question "What did you get done this week?"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
START_DATE=$(date -v -$(($(date '+%u') + 6))d '+%Y-%m-%d') | |
END_DATE=$(date -v -$(date '+%u')d '+%Y-%m-%d') | |
GIT_LOG=$(git log --since="$START_DATE" --until="$END_DATE" --pretty=format:"%h %s" --no-merges) | |
[ -z "$GIT_LOG" ] && { echo "No commits found."; exit 1; } | |
PROMPT="In less than 200 characters, summarize the following git commit history to answer the question 'What did you get done this week?'. Answer in the style of Elon Musk. The reader is in a hurry, so make sure it's easy to digest quickly. Start with 'This week'. ':\n$GIT_LOG" | |
curl -s https://api.openai.com/v1/chat/completions \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $OPENAI_API_KEY" \ | |
-d "$(jq -n --arg prompt "$PROMPT" \ | |
'{ | |
"model": "gpt-4", | |
"messages": [{"role": "user", "content": $prompt}], | |
"max_tokens": 256 | |
}')" | jq -r '.choices[0].message.content' |
Use the --before tag instead of the --until tag.
why what does that do?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
haha. nice