Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugging Face API raising error "Uncaught app exception" & "raise Exception("Something went wrong!")" #206

Closed
Areebkhan02 opened this issue May 3, 2024 · 12 comments · Fixed by #207
Labels
bug bug!

Comments

@Areebkhan02
Copy link

Areebkhan02 commented May 3, 2024

Describe the bug
So I made a chatbot using a public repository and multiple online resources through Hugchat API and used the model "CohereForAI/c4ai-command-r-plus". I then proceeded to host it on streamlit. All was working fine and the prompts that I was giving it worked perfectly. I then commited my code and proceed to do another work. After 6 to 7 hours when I tried the bot it was saying "Exception: Something went wrong!". I looked into my vs code there as error which very precisely resembles the error identified in this post: https://github.com/Soulter/hugging-chat-api/issues/169

To Reproduce
To reproduce this error I am attaching my code here `# Imports
import os
from hugchat import hugchat
from hugchat.login import Login
from dotenv import load_dotenv

Load the environment variables

#load_dotenv()

Load the email and password from the environment variables

EMAIL = ''
PASSWD = ''

Sign in to the HugChat

user = Login(email=EMAIL, passwd=PASSWD)

Function to prepare the query

def prepare_query(user_inputs):
# Initialize the query
query = ""

# Add project-specific information



# Loop through the user inputs
for key, value in user_inputs.items():
    # Add the key and value to the query
    query += f"{key}: {value}\n"

# Add a new line at the end of the query
query += "Give me a solution for this issue or give me some information about it."

# Return the query
return query

Function to get the chatbot

def get_chatbot():

# Set the cookies path
COOKIES_PATH = "cookies.json"

# Save the cookies
cookies = user.login(cookie_dir_path=COOKIES_PATH)

# Initialize the chatbot
chatbot = hugchat.ChatBot(
    cookies=cookies.get_dict(), default_llm="CohereForAI/c4ai-command-r-plus"
)

# Return the chatbot
return chatbot

Function to get the response from the chatbot

def get_response(user_inputs):
# Get the chatbot
chatbot = get_chatbot()

# Prepare the query
query = prepare_query(user_inputs)

# Get the response from the chatbot
response = chatbot.chat(query)

# Return the response
return response

`
you can enter your own email and password. The error I am receiving is

2024-05-03 18:28:08.164 Uncaught app exception Traceback (most recent call last): File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script exec(code, module.__dict__) File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\pages\01_🤖_Simple_ChatBot.py", line 69, in <module> response = get_response(user_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 63, in get_response chatbot = get_chatbot() ^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 49, in get_chatbot cookies = user.login(cookie_dir_path=COOKIES_PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 47, in login location = self._get_auth_url() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 175, in _get_auth_url raise Exception("Something went wrong!") Exception: Something went wrong! 2024-05-03 18:32:31.068 Uncaught app exception Traceback (most recent call last): File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script exec(code, module.__dict__) File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\pages\01_🤖_Simple_ChatBot.py", line 69, in <module> response = get_response(user_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 63, in get_response chatbot = get_chatbot() ^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 49, in get_chatbot cookies = user.login(cookie_dir_path=COOKIES_PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 47, in login location = self._get_auth_url() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 175, in _get_auth_url raise Exception("Something went wrong!") Exception: Something went wrong! 2024-05-03 18:32:41.286 Uncaught app exception Traceback (most recent call last): File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script exec(code, module.__dict__) File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\pages\01_🤖_Simple_ChatBot.py", line 69, in <module> response = get_response(user_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 63, in get_response chatbot = get_chatbot() ^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 49, in get_chatbot cookies = user.login(cookie_dir_path=COOKIES_PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 47, in login location = self._get_auth_url() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 175, in _get_auth_url raise Exception("Something went wrong!") Exception: Something went wrong! 2024-05-03 18:36:21.048 Uncaught app exception Traceback (most recent call last): File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script exec(code, module.__dict__) File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\pages\01_🤖_Simple_ChatBot.py", line 69, in <module> response = get_response(user_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 63, in get_response chatbot = get_chatbot() ^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 49, in get_chatbot cookies = user.login(cookie_dir_path=COOKIES_PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 47, in login location = self._get_auth_url() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 175, in _get_auth_url raise Exception("Something went wrong!") Exception: Something went wrong! 2024-05-03 18:41:57.633 Uncaught app exception Traceback (most recent call last): File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script exec(code, module.__dict__) File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\pages\01_🤖_Simple_ChatBot.py", line 69, in <module> response = get_response(user_inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 63, in get_response chatbot = get_chatbot() ^^^^^^^^^^^^^ File "C:\Users\DELL\Documents\GitHub\IntelliCropPK_ChatBot\helper.py", line 49, in get_chatbot cookies = user.login(cookie_dir_path=COOKIES_PATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 47, in login location = self._get_auth_url() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\hugchat\login.py", line 175, in _get_auth_url raise Exception("Something went wrong!") Exception: Something went wrong!

Same error which was identified in the post.
Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

@Areebkhan02 Areebkhan02 added the bug bug! label May 3, 2024
@Areebkhan02
Copy link
Author

what I have already done is

  1. I have deleted the hugchat library and installed the lastest version
  2. have disconnected my hugging face account with hug chat and connected again

but nothing seems to work but it was working fine previously

@vuemquan
Copy link

vuemquan commented May 3, 2024

same

PS D:\chat> python new.py
Traceback (most recent call last):
File "D:\chat\new.py", line 9, in
cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)
File "C:\Program Files\Python310\lib\site-packages\hugchat\login.py", line 47, in login
location = self._get_auth_url()
File "C:\Program Files\Python310\lib\site-packages\hugchat\login.py", line 175, in _get_auth_url
raise Exception("Something went wrong!")
Exception: Something went wrong!

@Areebkhan02
Copy link
Author

@kokofixcomputers
Copy link
Contributor

please fix this!!!! same!

@kokofixcomputers
Copy link
Contributor

hey guys! i found a solution!

@kokofixcomputers
Copy link
Contributor

waiting for my pull request to get merged

@Areebkhan02
Copy link
Author

Please tell us the solution if there is any.

@kokofixcomputers
Copy link
Contributor

Please tell us the solution if there is any.

my pull request should fix this, just waiting for Soulter to create a new release

@Soulter
Copy link
Owner

Soulter commented May 3, 2024

Hey guys, I just released a version v0.4.4 that fixed the bug by @kokofixcomputers , you can update hugchat to check it again. Thanks @kokofixcomputers

@kokofixcomputers
Copy link
Contributor

Hey guys, I just released a version v0.4.4 that fixed the bug by @kokofixcomputers , you can update hugchat to check it again. Thanks @kokofixcomputers

thank you so much for responding quickly! i have my issue fixed!

@Areebkhan02
Copy link
Author

Thankyou @Soulter and @kokofixcomputers !!

@Soulter Soulter pinned this issue May 4, 2024
@kokofixcomputers
Copy link
Contributor

kokofixcomputers commented May 5, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants