Deaksh commited on
Commit
2a04ad9
·
verified ·
1 Parent(s): dd6f264

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -39
app.py CHANGED
@@ -1,59 +1,51 @@
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
 
7
  # Options for length and language
8
  length_options = ["Short", "Medium", "Long"]
9
- language_options = ["English", "Hindi","Kannada"]
10
-
11
 
12
  # Main app layout
13
  def main():
14
- # Get persona name from UI or user input
15
- persona = input("Enter Persona Name: ").strip()
16
-
17
- try:
18
- # Create instance of FewShotPosts with the selected persona
19
- fs = FewShotPosts(persona)
20
-
21
- # Print available tags for debugging
22
- print(f"Available Tags for {persona}: {fs.get_tags()}")
23
-
24
- # Example: Fetch posts based on user-defined criteria
25
- posts = fs.get_filtered_posts(length="Short", language="English", tag="Economy")
26
- print(posts)
27
-
28
- except FileNotFoundError as e:
29
- print(e)
30
- st.subheader("LinkedIn Post Generator: Codebasics")
31
 
32
- # Create three columns for the dropdowns
33
- col1, col2, col3 = st.columns(3)
34
 
35
- fs = FewShotPosts(persona)
36
- tags = fs.get_tags()
37
- with col1:
38
- # Dropdown for Topic (Tags)
39
- selected_tag = st.selectbox("Topic", options=tags)
40
 
41
- with col2:
42
- # Dropdown for Length
43
- selected_length = st.selectbox("Length", options=length_options)
 
 
 
 
 
 
44
 
45
- with col3:
46
- # Dropdown for Language
47
- selected_language = st.selectbox("Language", options=language_options)
48
 
 
 
49
 
 
 
50
 
51
- # Generate Button
52
- if st.button("Generate"):
53
- post = generate_post(persona,selected_length, selected_language, selected_tag)
54
- st.write(post)
 
55
 
 
 
56
 
57
  # Run the app
58
  if __name__ == "__main__":
59
- main()
 
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"]
7
+ 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__":
51
+ main()