Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from few_shot import FewShotPosts | |
| from post_generator import generate_post | |
| from preprocess import process_posts_for_persona | |
| # Options for length and language | |
| length_options = ["Short", "Medium", "Long"] | |
| language_options = ["English", "Hindi","Kannada"] | |
| # Main app layout | |
| def main(): | |
| # Get persona name from UI or user input | |
| persona = input("Enter Persona Name: ").strip() | |
| try: | |
| # Create instance of FewShotPosts with the selected persona | |
| fs = FewShotPosts(persona) | |
| # Print available tags for debugging | |
| print(f"Available Tags for {persona}: {fs.get_tags()}") | |
| # Example: Fetch posts based on user-defined criteria | |
| posts = fs.get_filtered_posts(length="Short", language="English", tag="Economy") | |
| print(posts) | |
| except FileNotFoundError as e: | |
| print(e) | |
| st.subheader("LinkedIn Post Generator: Codebasics") | |
| # Create three columns for the dropdowns | |
| col1, col2, col3 = st.columns(3) | |
| fs = FewShotPosts(persona) | |
| tags = fs.get_tags() | |
| with col1: | |
| # Dropdown for Topic (Tags) | |
| selected_tag = st.selectbox("Topic", options=tags) | |
| with col2: | |
| # Dropdown for Length | |
| selected_length = st.selectbox("Length", options=length_options) | |
| with col3: | |
| # Dropdown for Language | |
| selected_language = st.selectbox("Language", options=language_options) | |
| # Generate Button | |
| if st.button("Generate"): | |
| post = generate_post(persona,selected_length, selected_language, selected_tag) | |
| st.write(post) | |
| # Run the app | |
| if __name__ == "__main__": | |
| main() |