Jobanpreet commited on
Commit
9be9f15
·
verified ·
1 Parent(s): 7761c23

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -110
app.py DELETED
@@ -1,110 +0,0 @@
1
- import streamlit as st
2
- import re
3
- import openai
4
- from paraphrase_post import get_original_url , paraphrased_post
5
- from advance_post import google_search , advanced_post
6
-
7
-
8
- def main():
9
- st.title("LinkedIn Post Creator")
10
-
11
- # Initialize SessionState dictionary
12
- session_state = st.session_state
13
-
14
- if 'paraphrase' not in session_state:
15
- session_state.paraphrase = ""
16
- if 'keywords' not in session_state:
17
- session_state.keywords = ""
18
- if 'take_aways' not in session_state:
19
- session_state.take_aways = ""
20
- if 'highlights' not in session_state:
21
- session_state.highlights = ""
22
-
23
- if 'advancepost' not in session_state:
24
- session_state.advancepost = ""
25
-
26
- url = st.sidebar.text_input("Enter URL:", placeholder="Enter URL here...")
27
- openai_api_key=st.sidebar.text_input("API Key:",placeholder="Enter OpenAI API Key...")
28
- temperature= st.sidebar.select_slider(
29
- 'How much accurate post you want ?',
30
- options=['Less accuracy', 9, 8, 7, 6, 5,4,3 ,2,1,'High accuracy'])
31
- if temperature=='Less accuracy':
32
- temperature=10
33
- elif temperature=="High accuracy":
34
- temperature=0
35
- temperature=temperature/10
36
-
37
-
38
- if st.sidebar.button("Submit"):
39
- if url:
40
- if openai_api_key:
41
- original_url = get_original_url(url)
42
- match = re.match(r"https?://(?:www\.)?linkedin\.com/(posts|feed|pulse)/.*", original_url) # checking domain and url page (means it should only be a post nothing else like login page or something else)
43
-
44
- if match:
45
- try:
46
- session_state.paraphrase, session_state.keywords, session_state.take_aways, session_state.highlights = paraphrased_post(url ,openai_api_key , temperature)
47
- except (openai.AuthenticationError) as e:
48
- st.sidebar.error("Enter your valid API key")
49
- else:
50
- st.sidebar.error("Put a valid LinkedIn post url only")
51
- else:
52
- st.sidebar.error("Please enter API Key")
53
- else:
54
- st.sidebar.error("Please enter url")
55
-
56
-
57
-
58
- paraphrase_text=st.text_area("Generated LinkedIn post",value=session_state.paraphrase, height=400)
59
- # import pyperclip
60
- # if st.button('Copy'):
61
- # pyperclip.copy(paraphrase_text)
62
- # st.success('Text copied successfully!')
63
-
64
- if st.sidebar.toggle("Show Details") and session_state.keywords:
65
- st.write("Keywords:")
66
- for i, statement in enumerate(session_state.keywords, start=1):
67
- st.write(f"{i}. {statement}")
68
-
69
- st.write("Take Aways:")
70
- for i, statement in enumerate(session_state.take_aways, start=1):
71
- st.write(f"{i}. {statement}")
72
-
73
- st.write("Highlights:")
74
- for i, statement in enumerate(session_state.highlights, start=1):
75
- st.write(f"{i}. {statement}")
76
-
77
- #------------------------------------------------------------Advance LinkedIn post code below-----------------------------------------------------------------
78
-
79
- if st.sidebar.toggle("Advance LinkedIn Post"):
80
- google_api_key=st.sidebar.text_input("Google API Key:",placeholder="Enter Google Search API Key...")
81
- search_engine_id=st.sidebar.text_input("Search Engine ID:",placeholder="Enter Search Engine ID...")
82
- google_api_key = "AIzaSyDh-lkJh2Zef0t6UVqSu_w3njpucx40mDc"
83
- search_engine_id = "44bbd32a2b2fc4418"
84
- if st.sidebar.button("Generate Advance Post"):
85
- if google_api_key:
86
- if search_engine_id:
87
- all_links =google_search(session_state.paraphrase ,openai_api_key , google_api_key,search_engine_id)
88
- session_state.advancepost , docs=advanced_post(all_links ,openai_api_key ,session_state.paraphrase)
89
- if len(docs)==0:
90
- st.sidebar.error("Please Check your both credentials carefully")
91
-
92
-
93
-
94
- else:
95
- st.sidebar.error("Please enter Search Engine ID")
96
- else:
97
- st.sidebar.error("Please enter Google API Key")
98
- advance_post=st.text_area("Advance LinkedIn post",value=session_state.advancepost, height=400)
99
-
100
-
101
- # if st.button('Copy Advanced Post'):
102
- # pyperclip.copy(advance_post)
103
- # st.success('Text copied successfully!')
104
- #--------------------------------------------------------------------------------------------------------------------------------------------------------------
105
-
106
- if __name__ == "__main__":
107
- main()
108
-
109
-
110
-