Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,9 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
# bardKey = "aQjBGndz_p9qdmaTSfmedlQODTMCa8iPeurM5mlJbzBzLISxmHRjXS-SIhbK_WsL3WIFUA."
|
11 |
-
# os.environ.get('token')
|
12 |
-
|
13 |
-
def bardChat(data):
|
14 |
-
# Create a session object using the requests library
|
15 |
-
session = requests.Session()
|
16 |
-
|
17 |
-
# Set the headers for the session
|
18 |
-
session.headers = {
|
19 |
-
"Host": "bard.google.com",
|
20 |
-
"X-Same-Domain": "1",
|
21 |
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
|
22 |
-
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
23 |
-
"Origin": "https://bard.google.com",
|
24 |
-
"Referer": "https://bard.google.com/",
|
25 |
-
}
|
26 |
-
|
27 |
-
# Set the "__Secure-1PSID" cookie with the Bard API key
|
28 |
-
session.cookies.set("__Secure-1PSID", "aQjBGndz_p9qdmaTSfmedlQODTMCa8iPeurM5mlJbzBzLISxmHRjXS-SIhbK_WsL3WIFUA.")
|
29 |
-
|
30 |
-
# Create a Bard object with the session and a timeout of 30 seconds
|
31 |
-
bard = Bard(token="aQjBGndz_p9qdmaTSfmedlQODTMCa8iPeurM5mlJbzBzLISxmHRjXS-SIhbK_WsL3WIFUA.", session=session, timeout=30)
|
32 |
-
answer = bard.get_answer(data)['content']
|
33 |
-
print(answer)
|
34 |
-
reply = {
|
35 |
-
'message':answer,
|
36 |
-
'action':'null'
|
37 |
-
}
|
38 |
-
return reply
|
39 |
-
|
40 |
-
uinput = st.chat_input("Enter your message")
|
41 |
-
with st.chat_message("assistant"):
|
42 |
-
bardanswer = bardChat(uinput)
|
43 |
-
st.markdown(bardanswer['message'])
|
44 |
-
|
|
|
1 |
+
from hugchat import hugchat
|
2 |
+
chatbot = hugchat.ChatBot(cookie_path="cookies.json")
|
3 |
+
print(chatbot.chat("Hi"))
|
4 |
+
# Create a new conversation
|
5 |
+
id = chatbot.new_conversation()
|
6 |
+
chatbot.change_conversation(id)
|
7 |
+
# Get conversation list
|
8 |
+
conversation_list = chatbot.get_conversation_list()
|
9 |
+
print(chatbot.chat("what is the most important thing to know as a human"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|