CosmoAI commited on
Commit
5eb08a7
·
1 Parent(s): b593708

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -18
app.py CHANGED
@@ -1,23 +1,32 @@
1
  from hugchat import hugchat
2
- import streamlit as st
 
3
 
4
- cookie_path = 'cookies.json'
5
- chatbot = hugchat.ChatBot(cookie_path=cookie_path)
 
6
 
7
- response = chatbot.start_conversation('Hello!')
8
- print(response)
 
9
 
10
- # chatbot = hugchat.ChatBot(cookie_path="home/user/cookies.json")
11
- # with st.chat_message:
12
- # st.markdown(chatbot.chat("Hi"))
 
 
 
 
 
 
 
 
 
 
13
 
14
- # # Create a new conversation
15
- # id = chatbot.new_conversation()
16
- # chatbot.change_conversation(id)
17
-
18
- # # Get conversation list
19
- # conversation_list = chatbot.get_conversation_list()
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
+