tushar-r-pawar commited on
Commit
53d0cb7
·
verified ·
1 Parent(s): 6562504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -3,12 +3,24 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import streamlit as st
4
  import airllm
5
 
6
- # Load GEMMA 2B model and tokenizer
7
- tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-27b")
 
 
 
 
 
 
 
 
 
 
 
8
  model = AutoModelForCausalLM.from_pretrained(
9
  "google/gemma-2-27b",
10
  device_map="auto",
11
- torch_dtype=torch.bfloat16
 
12
  )
13
  # Load the base version of the model
14
  #model = AutoModelForCausalLM.from_pretrained(model_name)
@@ -18,14 +30,14 @@ air_llm = airllm.AirLLM(model, tokenizer)
18
 
19
  # Streamlit app configuration
20
  st.set_page_config(
21
- page_title="Chatbot with GEMMA 2B and AirLLM",
22
  page_icon="🤖",
23
  layout="wide",
24
  initial_sidebar_state="expanded",
25
  )
26
 
27
  # App title
28
- st.title("Conversational Chatbot with GEMMA 2B and AirLLM")
29
 
30
  # Sidebar configuration
31
  st.sidebar.header("Chatbot Configuration")
@@ -77,6 +89,6 @@ if st.button("Send"):
77
  st.sidebar.markdown(
78
  """
79
  ### About
80
- This is a conversational chatbot built using the base version of the GEMMA 2B model and AirLLM.
81
  """
82
  )
 
3
  import streamlit as st
4
  import airllm
5
 
6
+
7
+ from dotenv import load_dotenv
8
+
9
+ load_dotenv()
10
+
11
+
12
+ api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
13
+
14
+ # Retrieve the API token from the environment variables
15
+ api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
16
+
17
+ # Load GEMMA 27B model and tokenizer using the API token
18
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-27b", use_auth_token=api_token)
19
  model = AutoModelForCausalLM.from_pretrained(
20
  "google/gemma-2-27b",
21
  device_map="auto",
22
+ torch_dtype=torch.bfloat16,
23
+ use_auth_token=api_token
24
  )
25
  # Load the base version of the model
26
  #model = AutoModelForCausalLM.from_pretrained(model_name)
 
30
 
31
  # Streamlit app configuration
32
  st.set_page_config(
33
+ page_title="Chatbot with GEMMA 27B and AirLLM",
34
  page_icon="🤖",
35
  layout="wide",
36
  initial_sidebar_state="expanded",
37
  )
38
 
39
  # App title
40
+ st.title("Conversational Chatbot with GEMMA 27B and AirLLM")
41
 
42
  # Sidebar configuration
43
  st.sidebar.header("Chatbot Configuration")
 
89
  st.sidebar.markdown(
90
  """
91
  ### About
92
+ This is a conversational chatbot built using the base version of the GEMMA 27B model and AirLLM.
93
  """
94
  )