enotkrutoy commited on
Commit
ce0e085
·
verified ·
1 Parent(s): 87325dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -1,24 +1,24 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Use a pipeline as a high-level helper
5
- messages = [
6
- {"role": "user", "content": "Who are you?"}
7
  pipe = pipeline("text-generation", model="Leo022/Gemma_QA_For_Telegram_Bot")
8
 
9
  # Create a Streamlit app
10
- st.title("Gemma_QA_For_Telegram_Bot")
11
 
12
  # Create a text input for the user to enter their question
13
- question = st.text_input("Enter your question")
14
 
15
  # Create a button to submit the question
16
  if st.button("Submit"):
17
- # Use the pipeline to generate a response to the user's question
18
- response = pipe([{"role": "user", "content": question}])
19
- # Display the response to the user
20
- st.write("Response:", response[0]["generated_text"])
21
-
22
- # Run the app
23
- if __name__ == "__main__":
24
- st.run()
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Load the text-generation pipeline
 
 
5
  pipe = pipeline("text-generation", model="Leo022/Gemma_QA_For_Telegram_Bot")
6
 
7
  # Create a Streamlit app
8
+ st.title("Gemma QA for Telegram Bot")
9
 
10
  # Create a text input for the user to enter their question
11
+ question = st.text_input("Enter your question:")
12
 
13
  # Create a button to submit the question
14
  if st.button("Submit"):
15
+ if question.strip(): # Ensure the question is not empty
16
+ try:
17
+ # Use the pipeline to generate a response to the user's question
18
+ response = pipe(question, max_length=100, num_return_sequences=1)
19
+ # Display the response to the user
20
+ st.write("Response:", response[0]["generated_text"])
21
+ except Exception as e:
22
+ st.error(f"An error occurred: {e}")
23
+ else:
24
+ st.warning("Please enter a question before submitting.")