andrewtsegaye
commited on
Commit
•
d72c33b
1
Parent(s):
f028d1d
new changes
Browse files- gui/streamlit_app.py +24 -18
- quora/mail.py +18 -2
gui/streamlit_app.py
CHANGED
@@ -1,25 +1,29 @@
|
|
1 |
import streamlit as st
|
2 |
import phind
|
3 |
|
4 |
-
|
5 |
-
phind.
|
|
|
6 |
|
7 |
-
|
8 |
-
|
|
|
9 |
try:
|
10 |
-
|
11 |
result = phind.Completion.create(
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
18 |
return result.completion.choices[0].text
|
19 |
-
|
20 |
except Exception as e:
|
21 |
-
|
|
|
|
|
22 |
|
|
|
23 |
st.set_page_config(
|
24 |
page_title="gpt4freeGUI",
|
25 |
initial_sidebar_state="expanded",
|
@@ -30,19 +34,21 @@ st.set_page_config(
|
|
30 |
'About': "### gptfree GUI"
|
31 |
}
|
32 |
)
|
33 |
-
|
34 |
st.header('GPT4free GUI')
|
35 |
|
36 |
-
|
|
|
|
|
37 |
if st.button('🧠 Think'):
|
38 |
-
answer =
|
|
|
39 |
st.caption("Answer :")
|
40 |
st.markdown(answer)
|
41 |
|
42 |
-
|
43 |
hide_streamlit_style = """
|
44 |
<style>
|
45 |
footer {visibility: hidden;}
|
46 |
</style>
|
47 |
"""
|
48 |
-
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
|
|
1 |
import streamlit as st
|
2 |
import phind
|
3 |
|
4 |
+
# Set cloudflare clearance and user agent
|
5 |
+
phind.cloudflare_clearance = ''
|
6 |
+
phind.phind_api = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
|
7 |
|
8 |
+
|
9 |
+
def get_answer(question: str) -> str:
|
10 |
+
# Set cloudflare clearance cookie and get answer from GPT-4 model
|
11 |
try:
|
|
|
12 |
result = phind.Completion.create(
|
13 |
+
model='gpt-4',
|
14 |
+
prompt=question,
|
15 |
+
results=phind.Search.create(question, actualSearch=True),
|
16 |
+
creative=False,
|
17 |
+
detailed=False,
|
18 |
+
codeContext=''
|
19 |
+
)
|
20 |
return result.completion.choices[0].text
|
|
|
21 |
except Exception as e:
|
22 |
+
# Return error message if an exception occurs
|
23 |
+
return f'An error occurred: {e}. Please make sure you are using a valid cloudflare clearance token and user agent.'
|
24 |
+
|
25 |
|
26 |
+
# Set page configuration and add header
|
27 |
st.set_page_config(
|
28 |
page_title="gpt4freeGUI",
|
29 |
initial_sidebar_state="expanded",
|
|
|
34 |
'About': "### gptfree GUI"
|
35 |
}
|
36 |
)
|
|
|
37 |
st.header('GPT4free GUI')
|
38 |
|
39 |
+
# Add text area for user input and button to get answer
|
40 |
+
question_text_area = st.text_area(
|
41 |
+
'🤖 Ask Any Question :', placeholder='Explain quantum computing in 50 words')
|
42 |
if st.button('🧠 Think'):
|
43 |
+
answer = get_answer(question_text_area)
|
44 |
+
# Display answer
|
45 |
st.caption("Answer :")
|
46 |
st.markdown(answer)
|
47 |
|
48 |
+
# Hide Streamlit footer
|
49 |
hide_streamlit_style = """
|
50 |
<style>
|
51 |
footer {visibility: hidden;}
|
52 |
</style>
|
53 |
"""
|
54 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
quora/mail.py
CHANGED
@@ -38,7 +38,7 @@ class Emailnator:
|
|
38 |
return self.email
|
39 |
|
40 |
def get_message(self):
|
41 |
-
print("
|
42 |
|
43 |
while True:
|
44 |
sleep(2)
|
@@ -49,6 +49,7 @@ class Emailnator:
|
|
49 |
mail_token = loads(mail_token.text)["messageData"]
|
50 |
|
51 |
if len(mail_token) == 2:
|
|
|
52 |
print(mail_token[1]["messageID"])
|
53 |
break
|
54 |
|
@@ -63,4 +64,19 @@ class Emailnator:
|
|
63 |
return mail_context.text
|
64 |
|
65 |
def get_verification_code(self):
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
return self.email
|
39 |
|
40 |
def get_message(self):
|
41 |
+
print("Waiting for message...")
|
42 |
|
43 |
while True:
|
44 |
sleep(2)
|
|
|
49 |
mail_token = loads(mail_token.text)["messageData"]
|
50 |
|
51 |
if len(mail_token) == 2:
|
52 |
+
print("Message received!")
|
53 |
print(mail_token[1]["messageID"])
|
54 |
break
|
55 |
|
|
|
64 |
return mail_context.text
|
65 |
|
66 |
def get_verification_code(self):
|
67 |
+
message = self.get_message()
|
68 |
+
code = findall(r';">(\d{6,7})</div>', message)[0]
|
69 |
+
print(f"Verification code: {code}")
|
70 |
+
return code
|
71 |
+
|
72 |
+
def clear_inbox(self):
|
73 |
+
print("Clearing inbox...")
|
74 |
+
self.client.post(
|
75 |
+
"https://www.emailnator.com/delete-all",
|
76 |
+
json={"email": self.email},
|
77 |
+
)
|
78 |
+
print("Inbox cleared!")
|
79 |
+
|
80 |
+
def __del__(self):
|
81 |
+
if self.email:
|
82 |
+
self.clear_inbox()
|