Deaksh commited on
Commit
df4bd52
·
verified ·
1 Parent(s): fc37a0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -37
app.py CHANGED
@@ -1,6 +1,10 @@
1
  import streamlit as st
2
  from few_shot import FewShotPosts
3
  from post_generator import generate_post
 
 
 
 
4
 
5
  # Options for length and language
6
  length_options = ["Short", "Medium", "Long"]
@@ -8,43 +12,45 @@ language_options = ["English", "Hindi", "Kannada"]
8
 
9
  # Main app layout
10
  def main():
11
- st.title("LinkedIn Post Generator: Codebasics")
12
-
13
- # User Input for Persona
14
- persona = st.text_input("Enter Persona Name:", "").strip()
15
-
16
- if persona:
17
- try:
18
- # Create an instance of FewShotPosts
19
- fs = FewShotPosts(persona)
20
-
21
- # Fetch available tags dynamically
22
- tags = fs.get_tags()
23
-
24
- if not tags:
25
- st.warning("No tags found for this persona. Check the dataset.")
26
- return
27
-
28
- # Create three columns for dropdowns
29
- col1, col2, col3 = st.columns(3)
30
-
31
- with col1:
32
- selected_tag = st.selectbox("Topic", options=tags)
33
-
34
- with col2:
35
- selected_length = st.selectbox("Length", options=length_options)
36
-
37
- with col3:
38
- selected_language = st.selectbox("Language", options=language_options)
39
-
40
- # Generate Button
41
- if st.button("Generate"):
42
- post = generate_post(persona, selected_length, selected_language, selected_tag)
43
- st.subheader("Generated Post:")
44
- st.write(post)
45
-
46
- except FileNotFoundError as e:
47
- st.error(f"Error: {e}")
 
 
48
 
49
  # Run the app
50
  if __name__ == "__main__":
 
1
  import streamlit as st
2
  from few_shot import FewShotPosts
3
  from post_generator import generate_post
4
+ from preprocess import process_posts_for_persona
5
+
6
+ # Predefined personas
7
+ persona_options = ["Marketer", "Software Engineer", "Investor", "Management Consultant"]
8
 
9
  # Options for length and language
10
  length_options = ["Short", "Medium", "Long"]
 
12
 
13
  # Main app layout
14
  def main():
15
+ st.subheader("LinkedIn Post Generator: Codebasics")
16
+
17
+ # Dropdown for Persona Selection
18
+ persona = st.selectbox("Select Persona", options=persona_options)
19
+
20
+ try:
21
+ # Create instance of FewShotPosts with the selected persona
22
+ fs = FewShotPosts(persona)
23
+
24
+ # Print available tags for debugging
25
+ print(f"Available Tags for {persona}: {fs.get_tags()}")
26
+
27
+ # Example: Fetch posts based on user-defined criteria
28
+ posts = fs.get_filtered_posts(length="Short", language="English", tag="Economy")
29
+ print(posts)
30
+
31
+ except FileNotFoundError as e:
32
+ print(e)
33
+
34
+ # Create three columns for the dropdowns
35
+ col1, col2, col3 = st.columns(3)
36
+
37
+ tags = fs.get_tags()
38
+ with col1:
39
+ # Dropdown for Topic (Tags)
40
+ selected_tag = st.selectbox("Topic", options=tags)
41
+
42
+ with col2:
43
+ # Dropdown for Length
44
+ selected_length = st.selectbox("Length", options=length_options)
45
+
46
+ with col3:
47
+ # Dropdown for Language
48
+ selected_language = st.selectbox("Language", options=language_options)
49
+
50
+ # Generate Button
51
+ if st.button("Generate"):
52
+ post = generate_post(persona, selected_length, selected_language, selected_tag)
53
+ st.write(post)
54
 
55
  # Run the app
56
  if __name__ == "__main__":