Spaces:
Runtime error
Runtime error
| from hugchat import hugchat | |
| from hugchat.login import Login | |
| import streamlit as st | |
| # Log in to huggingface and grant authorization to huggingchat | |
| x=st.text_input('hugging face email' ) | |
| print(1) | |
| y=st.text_input('hugging face password',type="password") | |
| if x and y: | |
| sign = Login(x, y) | |
| cookies = sign.login() | |
| # Save cookies to the local directory | |
| cookie_path_dir = "./cookies_snapshot" | |
| sign.saveCookiesToDir(cookie_path_dir) | |
| # Load cookies when you restart your program: | |
| # sign = login(email, None) | |
| # cookies = sign.loadCookiesFromDir(cookie_path_dir) # This will detect if the JSON file exists, return cookies if it does and raise an Exception if it's not. | |
| prompt = st.chat_input("Say something") | |
| chatbot = hugchat.ChatBot(cookies=cookies.get_dict()) # or cookie_path="usercookies/<email>.json" | |
| chatbot.switch_llm(2) | |
| if prompt: | |
| st.write("User: "+prompt) | |
| # non stream response | |
| query_result = chatbot.query(prompt) | |
| st.write("Agent: "+query_result) # or query_result.text or query_result["text"] |