File size: 2,914 Bytes
75a787e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import streamlit as st
from post_generator import *

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

def main():
    st.title("🕵️ LinkedIn Content Generator")
    st.markdown(
        """<style>
        .css-1oe6wy4, .css-1y4p8pa {
            background-color: #f8f9fa;
            border-radius: 15px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        .css-1v0mbdj {
            background-color: #ffffff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }
        </style>
        """,
        unsafe_allow_html=True,
    )

    st.markdown("**The code replicates the writing style of the selected author and generates posts accordingly. You can customize the raw data to match any author of your choice.**")
    st.markdown("**Using meta models via Groq API and Prompt Engineering**")

    st.markdown("---")
    
    # ---- SIDEBAR FOR LLM MODEL SELECTION ----
    st.sidebar.header("LLM Settings")
    llm_options = [
        "llama-3.3-70b-versatile",
        "llama-3.2-1b-preview", 
        "llama-3.2-3b-preview", 
        "llama-3.3-70b-specdec", 
        "llama-3.1-8b-instant", 
        "llama-guard-3-8b", 
        "llama3-70b-8192", 
        "llama3-8b-8192"
        ]
    selected_llm = st.sidebar.selectbox("Select LLM", options=llm_options)

    # ---- CHOOSE POST PARAMETERS ----
    st.header("Choose Post Parameters")

    fs = FewShotPosts()
    tags = fs.get_tags()

    # 1) Topic Selector
    selected_tag = st.selectbox("Select a Topic", options=tags)

    # 2) Additional Knowledge (Tile Below Topic)
    #    This text area will feed extra context to the LLM about the selected topic
    st.subheader("Add Additional Knowledge")
    additional_context = st.text_area(
        "Enter any extra details or knowledge about the topic that the model should consider.",
        placeholder="e.g., special data points, new trends, or context you want to include..."
    )

    # 3) Length and Language
    col1, col2 = st.columns([1, 1])
    with col1:
        selected_length = st.selectbox("Select Length", options=length_options)
    with col2:
        selected_language = st.selectbox("Select Language", options=language_options)

    st.markdown("---")
    st.header("Generate Post")

    # Generate Button and Display
    if st.button("Generate"):
        # Pass additional_context into generate_post
        post = generate_post(
            length=selected_length,
            language=selected_language,
            tag=selected_tag,
            model_name=selected_llm,
            custom_context=additional_context
        )
        st.write(post)
    else:
        st.write("Click the button above to generate a LinkedIn post.")

    st.markdown("---")

if __name__ == "__main__":
    main()