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