Kaludi commited on
Commit
19ca9f6
1 Parent(s): 92e794b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +93 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from revChatGPT.V1 import Chatbot
3
+
4
+ def main():
5
+ # Set page title and description
6
+ st.set_page_config(page_title="AI Assistant: revChatGPT", page_icon=":speak_no_evil:")
7
+ st.subheader("AI Assistant: revChatGPT")
8
+ st.markdown("This app allows you to chat with ChatGPT using a reverse-engineered API library called [revChatGPT](https://github.com/acheong08/ChatGPT). Replies from ChatGPT are streamed back to the user in real-time, which gives the user an experience similar to how ChatGPT streams back its answers.")
9
+
10
+ # Add image to the sidebar
11
+ st.sidebar.image("https://i.ibb.co/z84mCfY/image-8.png", use_column_width=True)
12
+ # Create Streamlit sidebar
13
+ st.sidebar.subheader("Configuration")
14
+ st.sidebar.write("Create an account on [OpenAI's ChatGPT](https://chat.openai.com/) and save your credentials.")
15
+ auth_method = st.sidebar.selectbox("Authentication method:", ["Email/Password", "Session token", "Access token"])
16
+
17
+ # Show text input widgets based on selected authentication method
18
+ if auth_method == "Email/Password":
19
+ email = st.sidebar.text_input("Email:")
20
+ password = st.sidebar.text_input("Password:", type="password")
21
+ st.sidebar.markdown("## Authentication Methods")
22
+ st.sidebar.markdown("")
23
+ st.sidebar.markdown("#### Email/Password")
24
+ st.sidebar.write("Not supported for Google/Microsoft accounts")
25
+ st.sidebar.markdown("----")
26
+ st.sidebar.markdown("#### Session token")
27
+ st.sidebar.write("Comes from cookies on chat.openai.com as *\"__Secure-next-auth.session-token\"*")
28
+ st.sidebar.markdown("----")
29
+ st.sidebar.markdown("#### Access token")
30
+ st.sidebar.write("[https://chat.openai.com/api/auth/session](https://chat.openai.com/api/auth/session)")
31
+ if email != "" and password != "":
32
+ config = {"email": email, "password": password}
33
+
34
+ else:
35
+ st.write("**Please enter your email and password.**")
36
+ return
37
+ elif auth_method == "Session token":
38
+ session_token = st.sidebar.text_input("Session token:")
39
+ st.sidebar.markdown("## Authentication Methods")
40
+ st.sidebar.markdown("")
41
+ st.sidebar.markdown("#### Email/Password")
42
+ st.sidebar.write("Not supported for Google/Microsoft accounts")
43
+ st.sidebar.markdown("----")
44
+ st.sidebar.markdown("#### Session token")
45
+ st.sidebar.write("Comes from cookies on chat.openai.com as *\"__Secure-next-auth.session-token\"*")
46
+ st.sidebar.markdown("----")
47
+ st.sidebar.markdown("#### Access token")
48
+ st.sidebar.write("[https://chat.openai.com/api/auth/session](https://chat.openai.com/api/auth/session)")
49
+ if session_token != "":
50
+ config = {"session_token": session_token}
51
+ else:
52
+ st.write("**Please enter your session token.**")
53
+ return
54
+ else:
55
+ access_token = st.sidebar.text_input("Access token:")
56
+ st.sidebar.markdown("## Authentication Methods")
57
+ st.sidebar.markdown("")
58
+ st.sidebar.markdown("#### Email/Password")
59
+ st.sidebar.write("Not supported for Google/Microsoft accounts")
60
+ st.sidebar.markdown("----")
61
+ st.sidebar.markdown("#### Session token")
62
+ st.sidebar.write("Comes from cookies on chat.openai.com as *\"__Secure-next-auth.session-token\"*")
63
+ st.sidebar.markdown("----")
64
+ st.sidebar.markdown("#### Access token")
65
+ st.sidebar.write("[https://chat.openai.com/api/auth/session](https://chat.openai.com/api/auth/session)")
66
+ if access_token != "":
67
+ config = {"access_token": access_token}
68
+ else:
69
+ st.write("**Please enter your access token.**")
70
+ return
71
+
72
+ # Instantiate chatbot
73
+ chatbot = Chatbot(config=config)
74
+
75
+ # Get user input using text input widget
76
+ user_input = st.text_input("You: ", placeholder="Ask me anything ...", key="input")
77
+
78
+ if st.button("Submit", type="primary"):
79
+ st.markdown("----")
80
+ res_box = st.empty()
81
+
82
+ for data in chatbot.ask(user_input):
83
+ message = data["message"]
84
+ res_box.write("ChatGPT: " + message)
85
+
86
+ st.markdown("")
87
+ st.markdown("---")
88
+ st.markdown("")
89
+ st.markdown("<p style='text-align: center'><a href='https://github.com/Kaludii'>Github</a> | <a href='https://huggingface.co/Kaludi'>HuggingFace</a></p>", unsafe_allow_html=True)
90
+
91
+
92
+ if __name__ == "__main__":
93
+ main()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastai==2.7.4
2
+ huggingface_hub[fastai]
3
+ fastcore>=1.3.27
4
+ revChatGPT.V1