Spaces:
Sleeping
Sleeping
import streamlit as st | |
from few_shot import FewShotPosts | |
from post_generator import generate_post | |
# Options for length and language | |
length_options = ["Short", "Medium", "Long"] | |
language_options = ["English", "Hindi", "Kannada"] | |
# Main app layout | |
def main(): | |
st.title("LinkedIn Post Generator: Codebasics") | |
# User Input for Persona | |
persona = st.text_input("Enter Persona Name:", "").strip() | |
if persona: | |
try: | |
# Create an instance of FewShotPosts | |
fs = FewShotPosts(persona) | |
# Fetch available tags dynamically | |
tags = fs.get_tags() | |
if not tags: | |
st.warning("No tags found for this persona. Check the dataset.") | |
return | |
# Create three columns for dropdowns | |
col1, col2, col3 = st.columns(3) | |
with col1: | |
selected_tag = st.selectbox("Topic", options=tags) | |
with col2: | |
selected_length = st.selectbox("Length", options=length_options) | |
with col3: | |
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.subheader("Generated Post:") | |
st.write(post) | |
except FileNotFoundError as e: | |
st.error(f"Error: {e}") | |
# Run the app | |
if __name__ == "__main__": | |
main() | |