Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,32 @@
|
|
| 1 |
from hugchat import hugchat
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
#
|
| 16 |
-
# chatbot.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
# uinput = st.chat_input("How can I help you?")
|
| 21 |
-
# with st.chat_message:
|
| 22 |
-
# st.markdown(chatbot.chat(uinput))
|
| 23 |
-
|
|
|
|
| 1 |
from hugchat import hugchat
|
| 2 |
+
from hugchat.login import Login
|
| 3 |
+
import streamlit as st
|
| 4 |
|
| 5 |
+
# Log in to huggingface and grant authorization to huggingchat
|
| 6 |
+
sign = Login(mecosmo369@gmail.com, @_3SegZXGjrjff/)
|
| 7 |
+
cookies = sign.login()
|
| 8 |
|
| 9 |
+
# Save cookies to the local directory
|
| 10 |
+
cookie_path_dir = "./cookies_snapshot"
|
| 11 |
+
sign.saveCookiesToDir(cookie_path_dir)
|
| 12 |
|
| 13 |
+
# Create a ChatBot
|
| 14 |
+
chatbot = hugchat.ChatBot(cookies=cookies.get_dict()) # or cookie_path="usercookies/<email>.json"
|
| 15 |
+
print(chatbot.chat("Hi!"))
|
| 16 |
+
|
| 17 |
+
# Create a new conversation
|
| 18 |
+
id = chatbot.new_conversation()
|
| 19 |
+
chatbot.change_conversation(id)
|
| 20 |
+
|
| 21 |
+
# Get conversation list
|
| 22 |
+
conversation_list = chatbot.get_conversation_list()
|
| 23 |
+
if uinput := st.chat_input("How can I help you?"):
|
| 24 |
+
with st.chat_message:
|
| 25 |
+
st.markdown(chatbot.chat(uinput))
|
| 26 |
|
| 27 |
+
|
| 28 |
+
# # Switch model (default: meta-llama/Llama-2-70b-chat-hf. )
|
| 29 |
+
# chatbot.switch_llm(0) # Switch to `OpenAssistant/oasst-sft-6-llama-30b-xor`
|
| 30 |
+
# chatbot.switch_llm(1) # Switch to `meta-llama/Llama-2-70b-chat-hf`
|
| 31 |
+
|
| 32 |
+
|
|
|
|
|
|
|
|
|
|
|
|