SabaAnver commited on
Commit
da7818a
·
verified ·
1 Parent(s): 37f3c70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -23
app.py CHANGED
@@ -1,28 +1,16 @@
1
  import streamlit as st
2
- import requests
3
 
4
- # Hugging Face API details
5
- API_URL = "https://api-inference.huggingface.co/models/gpt2"
6
- headers = {"Authorization": "Bearer YOUR_HF_API_TOKEN"} # <-- replace with your token
7
 
8
- def query(payload):
9
- response = requests.post(API_URL, headers=headers, json=payload)
10
- return response.json()
11
-
12
- st.title(" AI Quote Generator")
13
- st.write("Generate inspiring quotes using Hugging Face + Streamlit")
14
-
15
- topic = st.text_input("Enter a topic (e.g., happiness, love, success):", "")
16
 
17
  if st.button("Generate Quote"):
18
- if topic.strip() == "":
19
- prompt = "Here is an inspiring quote:"
20
- else:
21
- prompt = f"Here is an inspiring quote about {topic}:"
22
-
23
- output = query({"inputs": prompt, "max_length": 50, "num_return_sequences": 1})
24
-
25
- if isinstance(output, list) and len(output) > 0:
26
- st.success(output[0]['generated_text'])
27
- else:
28
- st.error("Something went wrong. Try again.")
 
1
  import streamlit as st
2
+ import random
3
 
4
+ st.title("✨ Simple Quote Generator")
5
+ st.write("Click the button to get an inspiring quote!")
 
6
 
7
+ quotes = [
8
+ "The best way to get started is to quit talking and begin doing.",
9
+ "Don’t let yesterday take up too much of today.",
10
+ "It’s not whether you get knocked down, it’s whether you get up.",
11
+ "If you are working on something exciting, it will keep you motivated.",
12
+ "Success is not in what you have, but who you are."
13
+ ]
 
14
 
15
  if st.button("Generate Quote"):
16
+ st.success(random.choice(quotes))