Spaces:
Sleeping
Sleeping
Merge pull request #10 from umbc-scify/version_0.1_setup
Browse files- .gitignore +2 -1
- app.py +50 -2
- hash.py +9 -0
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
*.DS_Store
|
|
|
|
|
|
| 1 |
+
*.DS_Store
|
| 2 |
+
.streamlit/secrets.toml
|
app.py
CHANGED
|
@@ -1,9 +1,57 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import random
|
| 3 |
import time
|
|
|
|
|
|
|
| 4 |
|
| 5 |
st.header(" Scientific Claim Verification ")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
st.caption("Team UMBC-SBU-UT")
|
| 8 |
|
| 9 |
# Initialize chat history
|
|
@@ -53,10 +101,10 @@ if prompt := st.chat_input("Type here"):
|
|
| 53 |
with st.chat_message("user"):
|
| 54 |
st.markdown(prompt)
|
| 55 |
|
| 56 |
-
|
| 57 |
retrieved_documents=retriever(prompt)
|
| 58 |
|
| 59 |
-
|
| 60 |
reasoning = reasoner(retrieved_documents)
|
| 61 |
|
| 62 |
# Display assistant response in chat message container
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import random
|
| 3 |
import time
|
| 4 |
+
import hmac
|
| 5 |
+
import bcrypt
|
| 6 |
|
| 7 |
st.header(" Scientific Claim Verification ")
|
| 8 |
|
| 9 |
+
def check_password():
|
| 10 |
+
"""Returns `True` if the user had a correct password."""
|
| 11 |
+
|
| 12 |
+
def login_form():
|
| 13 |
+
"""Form with widgets to collect user information"""
|
| 14 |
+
with st.form("Credentials"):
|
| 15 |
+
st.text_input("Username", key="username")
|
| 16 |
+
st.text_input("Password", type="password", key="password")
|
| 17 |
+
st.form_submit_button("Log in", on_click=password_entered)
|
| 18 |
+
|
| 19 |
+
def password_entered():
|
| 20 |
+
"""Checks whether a password entered by the user is correct."""
|
| 21 |
+
|
| 22 |
+
if st.session_state["username"] in st.secrets["passwords"]:
|
| 23 |
+
stored_hashed_password = st.secrets["passwords"][st.session_state["username"]] # Retrieved as a string
|
| 24 |
+
|
| 25 |
+
# Convert hashed password back to bytes if it's stored as a string
|
| 26 |
+
if isinstance(stored_hashed_password, str):
|
| 27 |
+
stored_hashed_password = stored_hashed_password.encode()
|
| 28 |
+
|
| 29 |
+
# Compare user-entered password (encoded) with stored hash
|
| 30 |
+
if bcrypt.checkpw(st.session_state["password"].encode(), stored_hashed_password):
|
| 31 |
+
st.session_state["password_correct"] = True
|
| 32 |
+
del st.session_state["password"] # Remove credentials from session
|
| 33 |
+
del st.session_state["username"]
|
| 34 |
+
return
|
| 35 |
+
|
| 36 |
+
# If authentication fails
|
| 37 |
+
st.session_state["password_correct"] = False
|
| 38 |
+
|
| 39 |
+
# Return True if the username + password is validated.
|
| 40 |
+
if st.session_state.get("password_correct", False):
|
| 41 |
+
return True
|
| 42 |
+
|
| 43 |
+
# Show inputs for username + password.
|
| 44 |
+
login_form()
|
| 45 |
+
if "password_correct" in st.session_state:
|
| 46 |
+
st.error("😕 User not known or password incorrect")
|
| 47 |
+
return False
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
if not check_password():
|
| 51 |
+
st.stop()
|
| 52 |
+
|
| 53 |
+
#Start of the Agentic Demo
|
| 54 |
+
|
| 55 |
st.caption("Team UMBC-SBU-UT")
|
| 56 |
|
| 57 |
# Initialize chat history
|
|
|
|
| 101 |
with st.chat_message("user"):
|
| 102 |
st.markdown(prompt)
|
| 103 |
|
| 104 |
+
|
| 105 |
retrieved_documents=retriever(prompt)
|
| 106 |
|
| 107 |
+
|
| 108 |
reasoning = reasoner(retrieved_documents)
|
| 109 |
|
| 110 |
# Display assistant response in chat message container
|
hash.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import bcrypt
|
| 2 |
+
|
| 3 |
+
def hash_password(password: str) -> str:
|
| 4 |
+
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
|
| 5 |
+
return hashed.decode()
|
| 6 |
+
|
| 7 |
+
new_password = ""
|
| 8 |
+
hashed_password = hash_password(new_password)
|
| 9 |
+
print(f"Hashed Password: {hashed_password}")
|