File size: 1,533 Bytes
6d0c6c2
 
 
 
 
 
2a04ad9
6d0c6c2
 
 
2a04ad9
6d0c6c2
2a04ad9
 
6d0c6c2
2a04ad9
 
 
 
6d0c6c2
2a04ad9
 
 
 
 
 
 
 
 
6d0c6c2
2a04ad9
 
6d0c6c2
2a04ad9
 
6d0c6c2
2a04ad9
 
6d0c6c2
2a04ad9
 
 
 
 
6d0c6c2
2a04ad9
 
6d0c6c2
 
 
2a04ad9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
50
51
52
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()