diff --git a/.envrc b/.envrc index 490e3b1..5c5cd28 100644 --- a/.envrc +++ b/.envrc @@ -21,3 +21,7 @@ export USE_PORTKEY="0" # Model specific options export MODEL_ID="qwen/Qwen2-7B-Instruct" export STOP_TOKEN="<|endoftext|>" + +# Streamlit configurations +export AUTH_CONFIG_FILE_PATH=".streamlit/config.yaml" +export STREAMLIT_CLIENT_SHOW_ERROR_DETAILS=False diff --git a/.streamlit/config.yaml b/.streamlit/config.yaml index 3377a9c..7a3191a 100644 --- a/.streamlit/config.yaml +++ b/.streamlit/config.yaml @@ -22,7 +22,13 @@ credentials: logged_in: false name: Sanket Test password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO - sameerk: + skulk3: + email: sameertest@gmail.com + failed_login_attempts: 0 + logged_in: false + name: Sameer Kulkarni + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + skulk4: email: sameertest@gmail.com failed_login_attempts: 0 logged_in: false diff --git a/k8s-manifests/configmap.yaml b/k8s-manifests/configmap.yaml new file mode 100644 index 0000000..ea7852e --- /dev/null +++ b/k8s-manifests/configmap.yaml @@ -0,0 +1,52 @@ +apiVersion: v1 +data: + config.yaml: |- + cookie: + expiry_days: 30 + key: some_signature_key + name: some_cookie_name + credentials: + usernames: + jdoe: + email: jdoe@gmail.com + failed_login_attempts: 0 + logged_in: false + name: John Doe + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + stest: + email: sankettest@gmail.com + failed_login_attempts: 0 + logged_in: false + name: Sanket Test + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + stest2: + email: sankettest@gmail.com + failed_login_attempts: 0 + logged_in: false + name: Sanket Test + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + skulk3: + email: sameertest@gmail.com + failed_login_attempts: 0 + logged_in: false + name: Sameer Kulkarni + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + skulk4: + email: sameertest@gmail.com + failed_login_attempts: 0 + logged_in: false + name: Sameer Kulkarni + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + amanj: + email: amantest@gmail.com + failed_login_attempts: 0 + logged_in: false + name: Aman Juneja + password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO + pre-authorized: + emails: + - melsby@gmail.com +kind: ConfigMap +metadata: + creationTimestamp: null + name: insightful-auth-config diff --git a/k8s-manifests/deploy.yaml b/k8s-manifests/deploy.yaml index 4a8308b..c0ae751 100644 --- a/k8s-manifests/deploy.yaml +++ b/k8s-manifests/deploy.yaml @@ -59,6 +59,8 @@ spec: readOnly: true - name: empty mountPath: /tmp/ + - name: auth-config + mountPath: /opt/auth-config dnsPolicy: ClusterFirst nodeSelector: kubernetes.io/hostname: infracloud02 @@ -71,5 +73,8 @@ spec: secret: defaultMode: 420 secretName: gh-pat + - name: auth-config + configMap: + name: insightful-auth-config - name: empty emptyDir: {} diff --git a/k8s-manifests/env.yaml b/k8s-manifests/env.yaml index 6377300..ce9f1bd 100644 --- a/k8s-manifests/env.yaml +++ b/k8s-manifests/env.yaml @@ -17,3 +17,7 @@ data: PORTKEY_CUSTOM_HOST: "llm_provider_host_ip_and_port" USE_PORTKEY: "0" USE_RERANKER: "1" + AUTH_CONFIG_FILE_PATH: "/opt/auth-config/config.yaml" + MODEL_ID: "meta-llama/Meta-Llama-3.1-8B-Instruct" + STOP_TOKEN: "<|endoftext|>" + STREAMLIT_CLIENT_SHOW_ERROR_DETAILS: False diff --git a/multi_tenant_rag.py b/multi_tenant_rag.py index 9893e3a..43f6267 100644 --- a/multi_tenant_rag.py +++ b/multi_tenant_rag.py @@ -22,7 +22,9 @@ logging.basicConfig(format="%(asctime)s - %(message)s", level=logging.INFO) def configure_authenticator(): - with open(".streamlit/config.yaml") as file: + auth_config = os.getenv("AUTH_CONFIG_FILE_PATH", default=".streamlit/config.yaml") + print(f"auth_config: {auth_config}") + with open(file=auth_config) as file: config = yaml.load(file, Loader=SafeLoader) authenticator = stauth.Authenticate( @@ -42,6 +44,7 @@ def authenticate(op): name, authentication_status, username = authenticator.login() st.session_state["authentication_status"] = authentication_status st.session_state["username"] = username + st.session_state["name"] = name elif op == "register": try: ( @@ -164,5 +167,6 @@ def main(): if __name__ == "__main__": authenticator = authenticate("login") if st.session_state["authentication_status"]: - authenticator.logout() + st.sidebar.text(f"Welcome {st.session_state['username']}") + authenticator.logout(location="sidebar") main()