|
1 |
| -#!/usr/bin/env bash |
| 1 | +#/usr/bin/env bash |
2 | 2 |
|
3 | 3 | # Copyright (C) 2024 Intel Corporation
|
4 | 4 | # SPDX-License-Identifier: Apache-2.0
|
| 5 | + |
| 6 | +# Function to prompt for input and set environment variables |
| 7 | +prompt_for_env_var() { |
| 8 | + local var_name="$1" |
| 9 | + local prompt_message="$2" |
| 10 | + local default_value="$3" |
| 11 | + local mandatory="$4" |
| 12 | + |
| 13 | + if [[ "$mandatory" == "true" ]]; then |
| 14 | + while [[ -z "$value" ]]; do |
| 15 | + read -p "$prompt_message [default: \"${default_value}\"]: " value |
| 16 | + if [[ -z "$value" ]]; then |
| 17 | + echo "Input cannot be empty. Please try again." |
| 18 | + fi |
| 19 | + done |
| 20 | + else |
| 21 | + read -p "$prompt_message [default: \"${default_value}\"]: " value |
| 22 | + fi |
| 23 | + |
| 24 | + if [[ "$value" == "" ]]; then |
| 25 | + export "$var_name"="$default_value" |
| 26 | + else |
| 27 | + export "$var_name"="$value" |
| 28 | + fi |
| 29 | +} |
| 30 | + |
5 | 31 | pushd "../../../../../" > /dev/null
|
6 | 32 | source .set_env.sh
|
7 | 33 | popd > /dev/null
|
8 | 34 |
|
| 35 | +# Prompt the user for each required environment variable |
| 36 | +prompt_for_env_var "EMBEDDING_MODEL_ID" "Enter the EMBEDDING_MODEL_ID" "BAAI/bge-base-en-v1.5" false |
| 37 | +prompt_for_env_var "HUGGINGFACEHUB_API_TOKEN" "Enter the HUGGINGFACEHUB_API_TOKEN" "" true |
| 38 | +prompt_for_env_var "RERANK_MODEL_ID" "Enter the RERANK_MODEL_ID" "BAAI/bge-reranker-base" false |
| 39 | +prompt_for_env_var "LLM_MODEL_ID" "Enter the LLM_MODEL_ID" "meta-llama/Meta-Llama-3-8B-Instruct" false |
| 40 | +prompt_for_env_var "INDEX_NAME" "Enter the INDEX_NAME" "rag-redis" false |
| 41 | +prompt_for_env_var "NUM_CARDS" "Enter the number of Gaudi devices" "1" false |
| 42 | +prompt_for_env_var "host_ip" "Enter the host_ip" "$(curl ifconfig.me)" false |
| 43 | + |
| 44 | +#Query for enabling http_proxy |
| 45 | +prompt_for_env_var "http_proxy" "Enter the http_proxy." "" false |
| 46 | + |
| 47 | +#Query for enabling https_proxy |
| 48 | +prompt_for_env_var "https_proxy" "Enter the https_proxy." "" false |
| 49 | + |
| 50 | +#Query for enabling no_proxy |
| 51 | +prompt_for_env_var "no_proxy" "Enter the no_proxy." "" false |
| 52 | + |
| 53 | +# Query for enabling logging |
| 54 | +read -p "Enable logging? (yes/no): " logging && logging=$(echo "$logging" | tr '[:upper:]' '[:lower:]') |
| 55 | +if [[ "$logging" == "yes" || "$logging" == "y" ]]; then |
| 56 | + export LOGFLAG=true |
| 57 | +else |
| 58 | + export LOGFLAG=false |
| 59 | +fi |
| 60 | + |
| 61 | +# Query for enabling OpenTelemetry Tracing Endpoint |
| 62 | +read -p "Enable OpenTelemetry Tracing Endpoint? (yes/no): " telemetry && telemetry=$(echo "$telemetry" | tr '[:upper:]' '[:lower:]') |
| 63 | +if [[ "$telemetry" == "yes" || "$telemetry" == "y" ]]; then |
| 64 | + export JAEGER_IP=$(ip route get 8.8.8.8 | grep -oP 'src \K[^ ]+') |
| 65 | + export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=grpc://$JAEGER_IP:4317 |
| 66 | + export TELEMETRY_ENDPOINT=http://$JAEGER_IP:4318/v1/traces |
| 67 | + telemetry_flag=true |
| 68 | +else |
| 69 | + telemetry_flag=false |
| 70 | +fi |
| 71 | + |
| 72 | +# Generate the .env file |
| 73 | +cat <<EOF > .env |
| 74 | +#!/bin/bash |
| 75 | +# Set all required ENV values |
| 76 | +export TAG=${TAG} |
| 77 | +export EMBEDDING_MODEL_ID=${EMBEDDING_MODEL_ID} |
| 78 | +export HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN |
| 79 | +export RERANK_MODEL_ID=${RERANK_MODEL_ID} |
| 80 | +export LLM_MODEL_ID=${LLM_MODEL_ID} |
| 81 | +export INDEX_NAME=${INDEX_NAME} |
| 82 | +export NUM_CARDS=${NUM_CARDS} |
| 83 | +export host_ip=${host_ip} |
| 84 | +export http_proxy=${http_proxy} |
| 85 | +export https_proxy=${https_proxy} |
| 86 | +export no_proxy=${no_proxy} |
| 87 | +export LOGFLAG=${LOGFLAG} |
| 88 | +export JAEGER_IP=${JAEGER_IP} |
| 89 | +export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT} |
| 90 | +export TELEMETRY_ENDPOINT=${TELEMETRY_ENDPOINT} |
| 91 | +EOF |
9 | 92 |
|
10 |
| -export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5" |
11 |
| -export RERANK_MODEL_ID="BAAI/bge-reranker-base" |
12 |
| -export LLM_MODEL_ID="meta-llama/Meta-Llama-3-8B-Instruct" |
13 |
| -export INDEX_NAME="rag-redis" |
14 |
| -export NUM_CARDS=1 |
15 |
| -# Set it as a non-null string, such as true, if you want to enable logging facility, |
16 |
| -# otherwise, keep it as "" to disable it. |
17 |
| -export LOGFLAG="" |
18 |
| -# Set OpenTelemetry Tracing Endpoint |
19 |
| -export JAEGER_IP=$(ip route get 8.8.8.8 | grep -oP 'src \K[^ ]+') |
20 |
| -export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=grpc://$JAEGER_IP:4317 |
21 |
| -export TELEMETRY_ENDPOINT=http://$JAEGER_IP:4318/v1/traces |
22 |
| -export no_proxy="$no_proxy,chatqna-gaudi-ui-server,chatqna-gaudi-backend-server,dataprep-redis-service,tei-embedding-service,retriever,tei-reranking-service,tgi-gaudi-server,vllm-gaudi-server,guardrails,jaeger,prometheus,grafana,node-exporter,gaudi-exporter,$JAEGER_IP" |
23 |
| - |
24 |
| -export LLM_ENDPOINT_PORT=8010 |
25 |
| -export LLM_SERVER_PORT=9001 |
26 |
| -export CHATQNA_BACKEND_PORT=8888 |
27 |
| -export CHATQNA_REDIS_VECTOR_PORT=6379 |
28 |
| -export CHATQNA_REDIS_VECTOR_INSIGHT_PORT=8001 |
29 |
| -export CHATQNA_FRONTEND_SERVICE_PORT=5173 |
30 |
| -export NGINX_PORT=80 |
31 |
| -export FAQGen_COMPONENT_NAME="OpeaFaqGenvLLM" |
32 |
| -export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}" |
| 93 | +echo ".env file has been created with the following content:" |
| 94 | +cat .env |
0 commit comments