Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,7 +93,7 @@ def read_email():
|
|
| 93 |
except Exception as e:
|
| 94 |
print(f"Error reading emails: {e}")
|
| 95 |
|
| 96 |
-
def load_llm_model():
|
| 97 |
try:
|
| 98 |
# Check if GPU is available and set the device accordingly
|
| 99 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -369,7 +369,7 @@ def change_bg_color(color):
|
|
| 369 |
unsafe_allow_html=True
|
| 370 |
)
|
| 371 |
|
| 372 |
-
def start(running):
|
| 373 |
while running:
|
| 374 |
try:
|
| 375 |
print('Started running...')
|
|
@@ -389,15 +389,17 @@ st.title("Streamlit LLM App")
|
|
| 389 |
# Display buttons for starting and stopping the core function
|
| 390 |
if st.button("Start"):
|
| 391 |
st.write('Model loading...') # Display a label when the model is loading
|
| 392 |
-
change_bg_color("
|
| 393 |
-
load_llm_model() # Load the model
|
|
|
|
| 394 |
st.success('Model loaded successfully!')
|
| 395 |
if st.button('Analyse'):
|
|
|
|
| 396 |
st.write('analyze started ! ...') # Show success message when model is loaded
|
| 397 |
-
start('True')
|
| 398 |
change_bg_color("lightgreen") # Change background color to green after loading
|
| 399 |
|
| 400 |
if st.button("Stop"):
|
| 401 |
st.write('Process stopped.') # Display stop message
|
| 402 |
change_bg_color("white") # Reset background color
|
| 403 |
-
start('False')
|
|
|
|
| 93 |
except Exception as e:
|
| 94 |
print(f"Error reading emails: {e}")
|
| 95 |
|
| 96 |
+
async def load_llm_model():
|
| 97 |
try:
|
| 98 |
# Check if GPU is available and set the device accordingly
|
| 99 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 369 |
unsafe_allow_html=True
|
| 370 |
)
|
| 371 |
|
| 372 |
+
async def start(running):
|
| 373 |
while running:
|
| 374 |
try:
|
| 375 |
print('Started running...')
|
|
|
|
| 389 |
# Display buttons for starting and stopping the core function
|
| 390 |
if st.button("Start"):
|
| 391 |
st.write('Model loading...') # Display a label when the model is loading
|
| 392 |
+
change_bg_color("lightyellow") # Change background color to yellow
|
| 393 |
+
await load_llm_model() # Load the model
|
| 394 |
+
change_bg_color("lightblue")
|
| 395 |
st.success('Model loaded successfully!')
|
| 396 |
if st.button('Analyse'):
|
| 397 |
+
change_bg_color('white')
|
| 398 |
st.write('analyze started ! ...') # Show success message when model is loaded
|
| 399 |
+
await start('True')
|
| 400 |
change_bg_color("lightgreen") # Change background color to green after loading
|
| 401 |
|
| 402 |
if st.button("Stop"):
|
| 403 |
st.write('Process stopped.') # Display stop message
|
| 404 |
change_bg_color("white") # Reset background color
|
| 405 |
+
await start('False')
|