Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 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"]
|
|
@@ -8,43 +12,45 @@ language_options = ["English", "Hindi", "Kannada"]
|
|
| 8 |
|
| 9 |
# Main app layout
|
| 10 |
def main():
|
| 11 |
-
st.
|
| 12 |
-
|
| 13 |
-
#
|
| 14 |
-
persona = st.
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Run the app
|
| 50 |
if __name__ == "__main__":
|
|
|
|
| 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 |
+
# Predefined personas
|
| 7 |
+
persona_options = ["Marketer", "Software Engineer", "Investor", "Management Consultant"]
|
| 8 |
|
| 9 |
# Options for length and language
|
| 10 |
length_options = ["Short", "Medium", "Long"]
|
|
|
|
| 12 |
|
| 13 |
# Main app layout
|
| 14 |
def main():
|
| 15 |
+
st.subheader("LinkedIn Post Generator: Codebasics")
|
| 16 |
+
|
| 17 |
+
# Dropdown for Persona Selection
|
| 18 |
+
persona = st.selectbox("Select Persona", options=persona_options)
|
| 19 |
+
|
| 20 |
+
try:
|
| 21 |
+
# Create instance of FewShotPosts with the selected persona
|
| 22 |
+
fs = FewShotPosts(persona)
|
| 23 |
+
|
| 24 |
+
# Print available tags for debugging
|
| 25 |
+
print(f"Available Tags for {persona}: {fs.get_tags()}")
|
| 26 |
+
|
| 27 |
+
# Example: Fetch posts based on user-defined criteria
|
| 28 |
+
posts = fs.get_filtered_posts(length="Short", language="English", tag="Economy")
|
| 29 |
+
print(posts)
|
| 30 |
+
|
| 31 |
+
except FileNotFoundError as e:
|
| 32 |
+
print(e)
|
| 33 |
+
|
| 34 |
+
# Create three columns for the dropdowns
|
| 35 |
+
col1, col2, col3 = st.columns(3)
|
| 36 |
+
|
| 37 |
+
tags = fs.get_tags()
|
| 38 |
+
with col1:
|
| 39 |
+
# Dropdown for Topic (Tags)
|
| 40 |
+
selected_tag = st.selectbox("Topic", options=tags)
|
| 41 |
+
|
| 42 |
+
with col2:
|
| 43 |
+
# Dropdown for Length
|
| 44 |
+
selected_length = st.selectbox("Length", options=length_options)
|
| 45 |
+
|
| 46 |
+
with col3:
|
| 47 |
+
# Dropdown for Language
|
| 48 |
+
selected_language = st.selectbox("Language", options=language_options)
|
| 49 |
+
|
| 50 |
+
# Generate Button
|
| 51 |
+
if st.button("Generate"):
|
| 52 |
+
post = generate_post(persona, selected_length, selected_language, selected_tag)
|
| 53 |
+
st.write(post)
|
| 54 |
|
| 55 |
# Run the app
|
| 56 |
if __name__ == "__main__":
|