using proxy
Browse files1212345567896789101112131411121315161516171718192021222324252627282930313233343536373839404142434445192021222324from hugchat import hugchatfrom hugchat.login import Loginimport aiohttpimport jsonimport re
email = "mihorag447@vikinoko.com"passwd = "IamstewpedW!23@"# Log in to huggingface and grant authorization to huggingchatsign = Login(email, passwd)# cookies = sign.login()class Hugging: def __init__(self): self.url = "https://p01--hugging--legal-stuff--a96n-7tyr.code.run/" self.headers = { "Authorization": "Bearer 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", "accept": "application/json", "content-type": "application/json", }
# # Save cookies to the local directorycookie_path_dir = "/srv/App/Generate/utils/cookies"sign.saveCookiesToDir(cookie_path_dir) async def chat(self, prompt: str):
# Load cookies when you restart your program:# sign = login(email, None)cookies = sign.loadCookiesFromDir(cookie_path_dir) payload = {"prompt": prompt}
print( { "hf-chat": "831aa60e-832c-4bc8-9609-feee1a63cabd", "token": "kybodoshVPnQLMIerSDRJjgLMnsoldLxjyoYHTdTsNWGXmOmdiGmQqjIXHDbwulMYnRqpnHkhwTcebrfTMxwXcVjLOfcPShwAJGzWwDTXjnxewKGgHICpagCZhnotfKA", }, "#" * 100,)# Create a ChatBotchatbot = hugchat.ChatBot( cookies={ "hf-chat": "831aa60e-832c-4bc8-9609-feee1a63cabd", "token": "kybodoshVPnQLMIerSDRJjgLMnsoldLxjyoYHTdTsNWGXmOmdiGmQqjIXHDbwulMYnRqpnHkhwTcebrfTMxwXcVjLOfcPShwAJGzWwDTXjnxewKGgHICpagCZhnotfKA", }, system_prompt="You are a true creative master genius and a great story teller that keeps the viewer/listener engauged. Make sure that you narrate the sequence of events properly so that the listener can understand. Use smart/insiteful quotes from the book. Don't speak to the viewers just tell the story accurately. Each scene should carry one topic and if the narration is long add more image_prompts, by default a short naration should have 2 image_prompts",)
model_index = 0models = chatbot.get_available_llm_models()print(chatbot.active_model)if not chatbot.active_model.name == "CohereForAI/c4ai-command-r-plus": for model in models: print(model.name, "switching..") if model.name == "CohereForAI/c4ai-command-r-plus": model_index = models.index(model) chatbot.switch_llm(model_index) break# print(chatbot.current_conversation.system_prompt) async with aiohttp.ClientSession() as session: async with session.post( self.url, headers=self.headers, data=json.dumps(payload) ) as response: result = await response.text() return resultApp/Generate/utils/HuggingChat.py+19-40