Skip to content

Login Exception #288

@Aravind4525

Description

@Aravind4525

from hugchat import hugchat
from hugchat.login import Login

email = ''
passwd = ''

Log in to Hugging Face and grant authorization to Hugging Chat

sign = Login(email, passwd)

cookies = sign.login()

Save cookies to the local directory

cookie_path_dir = "./cookies/"
cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)

sign.saveCookiesToDir(cookie_path_dir)

Create a ChatBot

chatbot = hugchat.ChatBot(cookies=cookies.get_dict())

chatbot.switch_llm(0) # 0 - CohereForAI/c4ai-command-r-plus [Falcon]

chatbot.switch_llm(8) # 9 - mistralai/Mistral-7B-Instruct-v0.2

def pi_ruby_chat_dev(prompt: str) -> str:

# Create a new conversation
id = chatbot.new_conversation()
chatbot.change_conversation(id)

# Send the Message
course_chat = chatbot.chat(f"{prompt}")

return course_chat.text

if name == 'main':
search_input = "Explain Pandas?"
message = f"Provide answer to the following question within 2 sentences. Ensure answer provided does not contain detailed examples and also does not contain any mathematical formulas, especially in latex format. - {search_input}"

stu_answer = "AWS Glue can be used for machine learning workflows by preparing and transforming raw data, cataloging in the view data cataloging, and then using the transformed data for training machine learning models in SageMake>

ques = "How do you use AWS Glue for machine learning workflows?"

ans = "AWS Glue can be used for machine learning workflows by preparing and transforming raw data, cataloging it in the Glue Data Catalog, and then using the transformed data for training machine learning models in SageMaker."

message = f"The following question is given by a faculty - {ques}. The correct answer to the above question provided by the faculty is - {ans}. Perform a Semantic Comparison and provide in percentage how close the student answer p>

result = pi_ruby_chat_dev(prompt=message)
print(result)

PS D:\Extraction of HTML> & 'd:\Extraction of HTML\env\Scripts\python.exe' 'c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy\launcher' '49635' '--' 'D:\Extraction of HTML\PiRuby_DB\chat_new.py'
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 88, in run_code
exec(code, run_globals)
File "c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy_main
.py", line 71, in
cli.main()
File "c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 501, in main
run()
File "c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 351, in run_file
runpy.run_path(target, run_name="main")
File "c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
_run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
File "c:\Users\Admin.vscode\extensions\ms-python.debugpy-2025.9.2025053001-win32-x64\bundled\libs\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
exec(code, run_globals)
File "D:\Extraction of HTML\PiRuby_DB\chat_new.py", line 19, in
cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\Extraction of HTML\env\Lib\site-packages\hugchat\login.py", line 47, in login
location = self._get_auth_url()
^^^^^^^^^^^^^^^^^^^^
File "d:\Extraction of HTML\env\Lib\site-packages\hugchat\login.py", line 176, in _get_auth_url
raise Exception("Something went wrong!")
Exception: Something went wrong!

still i am getting same error and i am using latest version 5

PS D:\Extraction of HTML> pip show hugchat
Name: hugchat
Version: 0.5.0
Summary: A huggingchat python api.
Home-page: https://github.com/Soulter/hugging-chat-api
Author: Soulter
Author-email: [email protected]
License: GNU Affero General Public License v3.0
Location: D:\Extraction of HTML\env\Lib\site-packages
Requires: requests, requests_toolbelt
Required-by:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions