JamalAG commited on
Commit
b6bf862
1 Parent(s): 84ac0b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -1,19 +1,19 @@
1
  import streamlit as st
2
- from transformers import pipeline, AutoModel
3
- import torch
 
4
 
5
  def main():
6
  st.title("Chatbot with Hugging Face Model")
7
 
8
  # Check if the model is already saved locally
9
- model_path = "./zephyr-7b-beta"
10
  try:
11
- pipe = pipeline("text-generation", model=model_path, torch_dtype=torch.bfloat16, device_map="auto")
12
  except:
13
  # If not saved, load the model and save it
14
  st.warning("Model not found locally. Downloading and saving the model. Please wait...")
15
  pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
16
- pipe.save_pretrained(model_path)
17
 
18
  # Define chat messages
19
  messages = [
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ MODEL_PATH = "zephyr_7b_beta_model"
5
 
6
  def main():
7
  st.title("Chatbot with Hugging Face Model")
8
 
9
  # Check if the model is already saved locally
 
10
  try:
11
+ pipe = pipeline("text-generation", model=MODEL_PATH, torch_dtype=torch.bfloat16, device_map="auto")
12
  except:
13
  # If not saved, load the model and save it
14
  st.warning("Model not found locally. Downloading and saving the model. Please wait...")
15
  pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
16
+ pipe.save_pretrained(MODEL_PATH)
17
 
18
  # Define chat messages
19
  messages = [