Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,59 +1,51 @@
|
|
1 |
import streamlit as st
|
2 |
from few_shot import FewShotPosts
|
3 |
from post_generator import generate_post
|
4 |
-
from preprocess import process_posts_for_persona
|
5 |
-
|
6 |
|
7 |
# Options for length and language
|
8 |
length_options = ["Short", "Medium", "Long"]
|
9 |
-
language_options = ["English", "Hindi","Kannada"]
|
10 |
-
|
11 |
|
12 |
# Main app layout
|
13 |
def main():
|
14 |
-
|
15 |
-
persona = input("Enter Persona Name: ").strip()
|
16 |
-
|
17 |
-
try:
|
18 |
-
# Create instance of FewShotPosts with the selected persona
|
19 |
-
fs = FewShotPosts(persona)
|
20 |
-
|
21 |
-
# Print available tags for debugging
|
22 |
-
print(f"Available Tags for {persona}: {fs.get_tags()}")
|
23 |
-
|
24 |
-
# Example: Fetch posts based on user-defined criteria
|
25 |
-
posts = fs.get_filtered_posts(length="Short", language="English", tag="Economy")
|
26 |
-
print(posts)
|
27 |
-
|
28 |
-
except FileNotFoundError as e:
|
29 |
-
print(e)
|
30 |
-
st.subheader("LinkedIn Post Generator: Codebasics")
|
31 |
|
32 |
-
#
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
selected_tag = st.selectbox("Topic", options=tags)
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
selected_language = st.selectbox("Language", options=language_options)
|
48 |
|
|
|
|
|
49 |
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
55 |
|
|
|
|
|
56 |
|
57 |
# Run the app
|
58 |
if __name__ == "__main__":
|
59 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from few_shot import FewShotPosts
|
3 |
from post_generator import generate_post
|
|
|
|
|
4 |
|
5 |
# Options for length and language
|
6 |
length_options = ["Short", "Medium", "Long"]
|
7 |
+
language_options = ["English", "Hindi", "Kannada"]
|
|
|
8 |
|
9 |
# Main app layout
|
10 |
def main():
|
11 |
+
st.title("LinkedIn Post Generator: Codebasics")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# User Input for Persona
|
14 |
+
persona = st.text_input("Enter Persona Name:", "").strip()
|
15 |
|
16 |
+
if persona:
|
17 |
+
try:
|
18 |
+
# Create an instance of FewShotPosts
|
19 |
+
fs = FewShotPosts(persona)
|
|
|
20 |
|
21 |
+
# Fetch available tags dynamically
|
22 |
+
tags = fs.get_tags()
|
23 |
+
|
24 |
+
if not tags:
|
25 |
+
st.warning("No tags found for this persona. Check the dataset.")
|
26 |
+
return
|
27 |
+
|
28 |
+
# Create three columns for dropdowns
|
29 |
+
col1, col2, col3 = st.columns(3)
|
30 |
|
31 |
+
with col1:
|
32 |
+
selected_tag = st.selectbox("Topic", options=tags)
|
|
|
33 |
|
34 |
+
with col2:
|
35 |
+
selected_length = st.selectbox("Length", options=length_options)
|
36 |
|
37 |
+
with col3:
|
38 |
+
selected_language = st.selectbox("Language", options=language_options)
|
39 |
|
40 |
+
# Generate Button
|
41 |
+
if st.button("Generate"):
|
42 |
+
post = generate_post(persona, selected_length, selected_language, selected_tag)
|
43 |
+
st.subheader("Generated Post:")
|
44 |
+
st.write(post)
|
45 |
|
46 |
+
except FileNotFoundError as e:
|
47 |
+
st.error(f"Error: {e}")
|
48 |
|
49 |
# Run the app
|
50 |
if __name__ == "__main__":
|
51 |
+
main()
|