File size: 1,714 Bytes
6d0c6c2
 
 
df4bd52
 
 
f52fa28
6d0c6c2
 
 
2a04ad9
6d0c6c2
 
 
df4bd52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
import streamlit as st
from few_shot import FewShotPosts
from post_generator import generate_post
from preprocess import process_posts_for_persona

# Predefined personas
persona_options = ["Marketer", "Software Engineer", "Investor", "Strategy Consultant"]

# Options for length and language
length_options = ["Short", "Medium", "Long"]
language_options = ["English", "Hindi", "Kannada"]

# Main app layout
def main():
    st.subheader("LinkedIn Post Generator: Codebasics")

    # Dropdown for Persona Selection
    persona = st.selectbox("Select Persona", options=persona_options)

    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)

    # Create three columns for the dropdowns
    col1, col2, col3 = st.columns(3)

    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()