ariankhalfani commited on
Commit
d9d3c6f
1 Parent(s): 0c103d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -9,7 +9,7 @@ if not HF_API_TOKEN:
9
  raise ValueError("Hugging Face API Token is not set in the environment variables.")
10
 
11
  # Hugging Face API URL and header for Gemma 27B-it model
12
- GEMMA_27B_API_URL = "https://api-inference.huggingface.co/models/google/gemma-2-27b-it"
13
 
14
  HEADERS = {"Authorization": f"Bearer {HF_API_TOKEN}"}
15
 
@@ -28,9 +28,9 @@ def extract_pdf_text(uploaded_file):
28
  return pdf_text
29
 
30
  # Streamlit app
31
- st.set_page_config(page_title="Gemma 27B-it Chatbot Interface", layout="wide")
32
- st.title("Gemma 27B-it Chatbot Interface")
33
- st.write("Gemma 27B-it Chatbot Interface")
34
 
35
  # Initialize session state for conversation and uploaded file
36
  if "conversation" not in st.session_state:
@@ -52,9 +52,9 @@ question = st.text_input("Ask a question...", "")
52
  if st.button("Send") and question:
53
  try:
54
  with st.spinner("Waiting for the model to respond..."):
55
- response = query_model(GEMMA_27B_API_URL, {"inputs": question})
56
  answer = response.get("generated_text", "No response")
57
- st.write(f"**Gemma 27B-it:** {answer}")
58
  st.session_state.conversation.append((question, answer))
59
  except ValueError as e:
60
  st.error(str(e))
@@ -93,5 +93,5 @@ if st.session_state.conversation:
93
  st.write('<div class="chat-container">', unsafe_allow_html=True)
94
  for user_message, bot_message in st.session_state.conversation:
95
  st.write(f'<div class="user-message">You: {user_message}</div>', unsafe_allow_html=True)
96
- st.write(f'<div class="bot-message">Gemma 27B-it: {bot_message}</div>', unsafe_allow_html=True)
97
  st.write('</div>', unsafe_allow_html=True)
 
9
  raise ValueError("Hugging Face API Token is not set in the environment variables.")
10
 
11
  # Hugging Face API URL and header for Gemma 27B-it model
12
+ GEMMA_9B_API_URL = "https://api-inference.huggingface.co/models/google/gemma-2-9b-it"
13
 
14
  HEADERS = {"Authorization": f"Bearer {HF_API_TOKEN}"}
15
 
 
28
  return pdf_text
29
 
30
  # Streamlit app
31
+ st.set_page_config(page_title="Gemma 9B-it Chatbot Interface", layout="wide")
32
+ st.title("Gemma 9B-it Chatbot Interface")
33
+ st.write("Gemma 9B-it Chatbot Interface")
34
 
35
  # Initialize session state for conversation and uploaded file
36
  if "conversation" not in st.session_state:
 
52
  if st.button("Send") and question:
53
  try:
54
  with st.spinner("Waiting for the model to respond..."):
55
+ response = query_model(GEMMA_9B_API_URL, {"inputs": question})
56
  answer = response.get("generated_text", "No response")
57
+ st.write(f"**Gemma 9B-it:** {answer}")
58
  st.session_state.conversation.append((question, answer))
59
  except ValueError as e:
60
  st.error(str(e))
 
93
  st.write('<div class="chat-container">', unsafe_allow_html=True)
94
  for user_message, bot_message in st.session_state.conversation:
95
  st.write(f'<div class="user-message">You: {user_message}</div>', unsafe_allow_html=True)
96
+ st.write(f'<div class="bot-message">Gemma 9B-it: {bot_message}</div>', unsafe_allow_html=True)
97
  st.write('</div>', unsafe_allow_html=True)