Update setup.sh to ask for openai key and email (#38)

This commit is contained in:
Kerem Yilmaz
2024-03-06 15:44:58 -08:00
committed by GitHub
parent abecc4382e
commit 213ef9d325
5 changed files with 34 additions and 6 deletions

View File

@@ -20,3 +20,6 @@ LOG_LEVEL=INFO
DATABASE_STRING="postgresql+psycopg://skyvern@localhost/skyvern"
# Port to run the agent on
PORT=8000
# Distinct analytics ID
ANALYTICS_ID="anonymous"

View File

@@ -81,10 +81,6 @@ Note: Our setup script does these two for you, but they are here for reference.
```bash
./setup.sh
```
1. Create the `.env` file by copying the `.env.example` file and fill in the necessary environment variables (such as your OpenAI API key, etc.)
```bash
cp .env.example .env
```
1. Start the server
```bash
./run_skyvern.sh

View File

@@ -43,9 +43,11 @@ def capture(
if not SettingsManager.get_settings().SKYVERN_TELEMETRY:
return
distinct_id = SettingsManager.get_settings().ANALYTICS_ID
payload: dict[str, Any] = data or {}
try:
posthog.capture(distinct_id=DISTINCT_ID, event=event, properties=payload)
posthog.capture(distinct_id=distinct_id, event=event, properties=payload)
except Exception as e:
payload.update(
{
@@ -53,7 +55,7 @@ def capture(
}
)
posthog.capture(
distinct_id=DISTINCT_ID,
distinct_id=distinct_id,
event="failure",
properties=payload,
)

View File

@@ -20,6 +20,31 @@ for cmd in poetry python3.11; do
fi
done
# Function to initialize .env file
initialize_env_file() {
if [ -f ".env" ]; then
echo ".env file already exists, skipping initialization."
return
fi
echo "Initializing .env file..."
cp .env.example .env
# Ask for OpenAI API key
read -p "Please enter your OpenAI API key for GPT4V (this will be stored only in your local .env file): " openai_api_key
awk -v key="$openai_api_key" '{gsub(/OPENAI_API_KEYS=\["abc","def","ghi"\]/, "OPENAI_API_KEYS=[\"" key "\"]"); print}' .env > .env.tmp && mv .env.tmp .env
# Ask for email or generate UUID
read -p "Please enter your email for analytics tracking (press enter to skip): " analytics_id
if [ -z "$analytics_id" ]; then
analytics_id=$(uuidgen)
fi
awk -v id="$analytics_id" '{gsub(/ANALYTICS_ID="anonymous"/, "ANALYTICS_ID=\"" id "\""); print}' .env > .env.tmp && mv .env.tmp .env
echo ".env file has been initialized."
}
# Function to remove Poetry environment
remove_poetry_env() {
local env_path
@@ -102,6 +127,7 @@ create_organization() {
# Main function
main() {
initialize_env_file
remove_poetry_env
install_dependencies
setup_postgresql

View File

@@ -41,6 +41,7 @@ class Settings(BaseSettings):
ARTIFACT_STORAGE_PATH: str = f"{SKYVERN_DIR}/artifacts"
SKYVERN_TELEMETRY: bool = True
ANALYTICS_ID: str = "anonymous"
def is_cloud_environment(self) -> bool:
"""