From 02635958060e0cbabf427e23da5c604e74737c90 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Sat, 25 Feb 2023 23:33:57 +0100 Subject: [PATCH] Add auto-start script --- .gitignore | 1 + start.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 start.sh diff --git a/.gitignore b/.gitignore index 82f0a25..92324df 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ Cargo.lock **/*.rs.bk .vscode/ Notes.md +openai.sk diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..c399127 --- /dev/null +++ b/start.sh @@ -0,0 +1,19 @@ +#!/bin/zsh + +if ! [ -f "target/release/ai_chat" ]; then + if ! cargo build --release; then + echo "Could not build binary! Press any key to exit..." >&2 + read + exit + fi +fi + +if ! [ -f "openai.sk" ]; then + echo -n "Enter OpenAI secret key: " + read -s OPENAI_SK +else + OPENAI_SK="$(cat openai.sk)" +fi + +export OPENAI_SK +target/release/ai_chat