Soulter / hugging-chat-api

HuggingChat Python API🤗
GNU Affero General Public License v3.0
859 stars 123 forks source link

Error: "An error occurred" #233

Closed Aravind4525 closed 5 months ago

Aravind4525 commented 5 months ago

ERROR:root:No type found in response: {'message': 'An error occurred', 'errorId': '872cc721-4df6-42ef-82c8-a56b35eafaa3'} Traceback (most recent call last): File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\bc_pi.py", line 154, in result = pisearch_courses(searchinput=input_text, course_content_id=course_content_id, standard=level, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\bc_ut.py", line 631, in inner f = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\bc_pi.py", line 17, in pisearch_courses print("chat_response : ", chat_response) File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\message.py", line 233, in str return self.wait_until_done() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\message.py", line 203, in wait_until_done self.next() File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\message.py", line 158, in next raise self.error File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\message.py", line 105, in next self._filterResponse(a) File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\message.py", line 89, in _filterResponse raise ChatError(f"Server returns an error: {obj['message']}") hugchat.exceptions.ChatError: Server returns an error: An error occurred Traceback (most recent call last): File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\hugchat.py", line 734, in _stream_query yield obj GeneratorExit Exception ignored in: <generator object ChatBot._stream_query at 0x000001FC2915D1B0> Traceback (most recent call last): File "C:\Users\Admin\PycharmProjects\New_PiCourseSearch\venv\Lib\site-packages\hugchat\hugchat.py", line 744, in _stream_query hugchat.exceptions.ChatError: Failed to parse response: {"message":"An error occurred","errorId":"872cc721-4df6-42ef-82c8-a56b35eafaa3"}

github-actions[bot] commented 5 months ago

Hi! Thanks for your issue, we will deal with your issue as soon as possible.

YWaller commented 5 months ago

I have also started getting this error. Glad to know it's not my code all of a sudden!

haytam776 commented 5 months ago

+1 Me too, my code before 3 hours ago work fine, but now it's not work with this error

Whitelisted1 commented 5 months ago

This seems to be because of the fact that HuggingChat has transitioned over to sending model queries as Form requests in order to send files, shown when we look at the request sent in HuggingChat:

------WebKitFormBoundaryXebZOGiPuxr6B21Z
Content-Disposition: form-data; name="data"

{"inputs":"Hi!","id":"c5a92bea-3722-4d8b-9a59-bfc2ea7bb0e4","is_retry":false,"is_continue":false,"web_search":false,"tools":{}}
------WebKitFormBoundaryXebZOGiPuxr6B21Z--
qahsi2004 commented 5 months ago

@Whitelisted1 Can you please suggest a solution for this issue? I have a project due by tomorrow and I really want to get it sorted out asap. Thank you.

YWaller commented 5 months ago

@qahsi2004 I intend this to be a very gentle rebuke, but: "your failure to plan ahead is not my emergency" should be his response. None of us are paying the guy. I've spent some time looking through message.py trying to sort it out myself and failing badly (meaning, no one rely on @YWaller to fix this lol), but it takes time. This isn't exactly a corporate sponsored git repo, aye?

If you need it that badly, all the code is in python. Dive in. Fix it. Add "open source contributor" to your resume. It's either in hugchat.py or message.py I'm pretty sure.

thomaspj10 commented 5 months ago

I've created a PR, which fixes this issue.

Soulter commented 5 months ago

Fixed this error in the latest version v0.4.8 and thanks @thomaspj10 .

Besugo03 commented 5 months ago

Sorry but i'm still getting this error... am i doing something wrong?

This is the code i am using:

from hugchat import hugchat
from hugchat.login import Login

EMAIL = # My email
PASSWD = # My passwd

sign = Login(EMAIL, PASSWD)
cookie_path_dir = "./cookies/" # NOTE: trailing slash (/) is required to avoid errors
cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)

# Create your ChatBot
chatbot = hugchat.ChatBot(cookies=cookies.get_dict())  # or cookie_path="usercookies/<email>.json"

# Non stream response
query_result = chatbot.chat("Hi!")
print(query_result) # or query_result.text or query_result["text"]

Output : > ERROR:root:No type found in response: {'message': 'An error occurred', 'errorId': 'd7a3030e-29c9-45a2-ad6f-4400733eaf4a'}

Exception has occurred: ChatError
Server returns an error: An error occurred
  File "C:\Users\alexp\Desktop\projects\hugchat_test.py", line 16, in <module>
    print(query_result) # or query_result.text or query_result["text"]
hugchat.exceptions.ChatError: Server returns an error: An error occurred

Output of "pip show" to show my current library version :

PS C:\Users\alexp\Desktop\projects> pip show hugchat     
Name: hugchat
Version: 0.4.8
Summary: A huggingchat python api.
Home-page: https://github.com/Soulter/hugging-chat-api
Author: Soulter
Author-email: 905617992@qq.com
License: GNU Affero General Public License v3.0
Location: c:\users\alexp\appdata\local\programs\python\python310\lib\site-packages
Requires: requests, requests-toolbelt
Required-by:
thomaspj10 commented 5 months ago

Works fine for me. Maybe re-install the package and restart your IDE? Is the package version installed under the correct Python version?

Besugo03 commented 5 months ago

Sorry, this was an error from my end. I didn't notice i had two python interpreters in VSCode and it ended up installing the new version only on another one. Works like a charm! thanks @thomaspj10 ❤️

tkarrergit commented 3 months ago

Hello, i have this Problem again! ERROR:root:No type found in response: {'message': 'An error occurred', 'errorId': 'e7d78ef5-83b1-4c78-9561-4334f60beda4'}

My Code: from hugchat import hugchat from hugchat.login import Login

EMAIL = "myemail" PASSWD = "mypasswort"

sign = Login(EMAIL, PASSWD) cookie_path_dir = "./cookies/" # NOTE: trailing slash (/) is required to avoid errors cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)

Create your ChatBot

chatbot = hugchat.ChatBot(cookies=cookies.get_dict()) # or cookie_path="usercookies/.json"

Non stream response

query_result = chatbot.chat("Hi!") print(query_result) # or query_result.text or query_result["text"]

What am I doing wrong? hugchat ver. 0.4.10

766670 commented 3 months ago

@tkarrergit Did you get any solution I am also facing same issue. As first it was running well but now same problem arises

I am using hugchat version 0.4.10

Soulter commented 3 months ago

@766670 @tkarrergit Hey guys, you can update to 0.4.11 and check it again.

nekronk commented 3 months ago

@tkarrergit Did you get any solution I am also facing same issue. As first it was running well but now same problem arises

I am using hugchat version 0.4.10

Had the same problem, but reinstalling the new version (0.4.11) helped