XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

new changes

d72c33b6
Andrew Tsegaye <andrewtsegaye7@gmail.com>
提交于

代码差异

2 个文件 +42 -20
Modified gui/streamlit_app.py +24 -18
@@ -1,25 +1,29 @@
1 1 import streamlit as st
2 2 import phind
3 3
4 phind.cf_clearance = ''
5 phind.user_agent = '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'
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'
6 7
7 def phind_get_answer(question:str)->str:
8 # set cf_clearance cookie
8
9 def get_answer(question: str) -> str:
10 # Set cloudflare clearance cookie and get answer from GPT-4 model
9 11 try:
10
11 12 result = phind.Completion.create(
12 model = 'gpt-4',
13 prompt = question,
14 results = phind.Search.create(question, actualSearch = True),
15 creative = False,
16 detailed = False,
17 codeContext = '')
13 model='gpt-4',
14 prompt=question,
15 results=phind.Search.create(question, actualSearch=True),
16 creative=False,
17 detailed=False,
18 codeContext=''
19 )
18 20 return result.completion.choices[0].text
19
20 21 except Exception as e:
21 return 'An error occured, please make sure you are using a cf_clearance token and correct useragent | %s' % 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
22 25
26 # Set page configuration and add header
23 27 st.set_page_config(
24 28 page_title="gpt4freeGUI",
25 29 initial_sidebar_state="expanded",
@@ -30,19 +34,21 @@ st.set_page_config(
30 34 'About': "### gptfree GUI"
31 35 }
32 36 )
33
34 37 st.header('GPT4free GUI')
35 38
36 question_text_area = st.text_area('🤖 Ask Any Question :', placeholder='Explain quantum computing in 50 words')
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')
37 42 if st.button('🧠 Think'):
38 answer = phind_get_answer(question_text_area)
43 answer = get_answer(question_text_area)
44 # Display answer
39 45 st.caption("Answer :")
40 46 st.markdown(answer)
41 47
42
48 # Hide Streamlit footer
43 49 hide_streamlit_style = """
44 50 <style>
45 51 footer {visibility: hidden;}
46 52 </style>
47 53 """
48 st.markdown(hide_streamlit_style, unsafe_allow_html=True)
54 st.markdown(hide_streamlit_style, unsafe_allow_html=True)
Modified quora/mail.py +18 -2
@@ -38,7 +38,7 @@ class Emailnator:
38 38 return self.email
39 39
40 40 def get_message(self):
41 print("waiting for code...")
41 print("Waiting for message...")
42 42
43 43 while True:
44 44 sleep(2)
@@ -49,6 +49,7 @@ class Emailnator:
49 49 mail_token = loads(mail_token.text)["messageData"]
50 50
51 51 if len(mail_token) == 2:
52 print("Message received!")
52 53 print(mail_token[1]["messageID"])
53 54 break
54 55
@@ -63,4 +64,19 @@ class Emailnator:
63 64 return mail_context.text
64 65
65 66 def get_verification_code(self):
66 return findall(r';">(\d{6,7})</div>', self.get_message())[0]
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()