Closed FBRDCYB3R closed 7 months ago
I also have different problems with web_search. Here's the info about the version of hugchat:
pip show hugchat
Name: hugchat
Version: 0.4.1
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: /home/folder/lib/python3.11/site-packages
Requires: requests, requests-toolbelt
Required-by:
I have tried the following prompt first with web_search
disabled:
>>> result = chatbot.chat('Hi, tell me a joke', web_search=False)
>>> print(result)
DEBUG:root:conversation 6616a49674912884dc720453 last message id: f5e42a5b-ad89-4f98-9e2a-71e915c0a731
DEBUG:urllib3.connectionpool:https://huggingface.co:443 "POST /chat/conversation/6616a49674912884dc720453 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Resetting dropped connection: huggingface.co
DEBUG:urllib3.connectionpool:https://huggingface.co:443 "POST /chat/conversation/6616a49674912884dc720453/__data.json HTTP/1.1" 200 None
DEBUG:root:conversation 6616a49674912884dc720453 history: [MessageNode(id='f5e42a5b-ad89-4f98-9e2a-71e915c0a731', role='system', content='', created_at=1712752758.921, updated_at=1712752758.921), MessageNode(id='a61bca8c-75f4-473e-a2c6-4a08c344125e', role='user', content='Hi, tell me a joke', created_at=1712752767.43, updated_at=1712752767.43), MessageNode(id='c1975a27-f77e-4291-bf53-3ac141099d6c', role='assistant', content=" Sure! Here's one:\n\nWhy don't scientists trust atoms?\n\nBecause they make up everything!\n\nI hope you found that amusing. Let me know if there is anything else I can help with.", created_at=1712752767.43, updated_at=1712752777.168)]
Sure! Here's one:
Why don't scientists trust atoms?
Because they make up everything!
I hope you found that amusing. Let me know if there is anything else I can help with.
With web_search
enabled:
>>> result = chatbot.chat('Find me a joke about boeing', web_sear
ch=True)
>>> print(result)
DEBUG:root:conversation 6616a49674912884dc720453 last message id: c44b1e12-78a6-4cf6-ba9b-640295d6a006
DEBUG:urllib3.connectionpool:https://huggingface.co:443 "POST /chat/conversation/6616a49674912884dc720453 HTTP/1.1" 200 None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 224, in __str__
return self.wait_until_done()
^^^^^^^^^^^^^^^^^^^^^^
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 194, in wait_until_done
self.__next__()
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 149, in __next__
raise self.error
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 141, in __next__
return self.__next__()
^^^^^^^^^^^^^^^
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 149, in __next__
raise self.error
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 141, in __next__
return self.__next__()
^^^^^^^^^^^^^^^
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 149, in __next__
raise self.error
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 141, in __next__
return self.__next__()
^^^^^^^^^^^^^^^
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 149, in __next__
raise self.error
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 141, in __next__
return self.__next__()
^^^^^^^^^^^^^^^
File "/home/folder/lib/python3.11/site-packages/hugchat/message.py", line 94, in __next__
raise self.error
hugchat.exceptions.ChatError: Failed to parse webpage
>>> ^D
Traceback (most recent call last):
File "/home/folder/lib/python3.11/site-packages/hugchat/hugchat.py", line 780, in _stream_query
yield obj
GeneratorExit
DEBUG:root:{'Content-Type': 'text/event-stream', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Wed, 10 Apr 2024 14:42:07 GMT', 'set-cookie': 'hf-chat=e79c423b-c83e-4de7-a6e5-9eb4e875e82f; Path=/; Expires=Wed, 24 Apr 2024 14:42:07 GMT; HttpOnly; Secure; SameSite=None', 'x-proxied-host': 'http://10.29.19.50', 'x-proxied-path': '/chat/conversation/6616a49674912884dc720453', 'link': '<https://huggingface.co/spaces/huggingchat/chat-ui>;rel="canonical"', 'x-request-id': '2a_IgQ', 'access-control-allow-origin': 'https://huggingface.co', 'access-control-allow-credentials': 'true', 'vary': 'origin, access-control-request-method, access-control-request-headers', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 461f986b60f99dda319d2b87307b2082.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'TXL50-P6', 'X-Amz-Cf-Id': '4WUZ4zrquw8BELevnyLWOGUj6I9K2-orxE3ZB0iT7NPMAB2hYQbpZQ=='}
Exception ignored in: <generator object ChatBot._stream_query at 0x7f5a73433870>
Traceback (most recent call last):
File "/home/folder/lib/python3.11/site-packages/hugchat/hugchat.py", line 790, in _stream_query
hugchat.exceptions.ChatError: Failed to parse response: {"type":"webSearch","messageType":"error","message":"Failed to parse webpage","args":["webpage doesn't have any parseable element","https://www.reddit.com/r/Jokes/comments/1bfzou7/a_group_of_boeing_employees_are_sitting_on_a/"]}
@Soulter if nobody works on this I can give it a try.
@reflectored Please look into. I have the same issue as you do.
@Soulter if nobody works on this I can give it a try.
hi, I've been a little bit busy recently so I didn't pay much attention to this issue timely, I'd appreciate it if you can work on this
When Web Search tries multiple sites and encounters one or more "Failed to parse webpage" errors, it should ignore the error and carry on to try next site. However currently the error is caught and raised. That's why it crashes out.
@cakemooner @Soulter Fixed it, did some refactoring as well #193.
I published a new version v0.4.2 that fixed the bug. Thanks @reflectored
I am using the outline provided in the readme, and I am able to access the site but its not able to search the web. When I ask it "todays news" it defaults to the date of August 13, 2023 and nor am I able to switch llm, it keeps defaulting to Mistral Ai, even when I specify `chatbot.switch_llm(1) # Switch to the second model
Get information about the current conversation
info = chatbot.get_conversation_info()
print(info.id, info.title, info.model, info.system_prompt, info.history)
Assistant
` and here is my version of the code I changed up a bit:
`from hugchat import hugchat from hugchat.login import Login
Log in to huggingface and grant authorization to huggingchat
EMAIL = "Kuzeshell69@gmail.com" PASSWD = "Wordpass197900" cookie_path_dir = "./cookies" sign = Login(EMAIL, PASSWD) cookies = sign.login(cookie_dir_path=cookie_path_dir, save_cookies=True)
Create your ChatBot
chatbot = hugchat.ChatBot(cookies=cookies.get_dict())
Function to get user input for query
def get_user_query(): query = input("Enter your query: ") return query
Main loop
while True: user_query = get_user_query() if user_query.lower() == "quit": break
Get information about the current conversation
info = chatbot.get_conversation_info()
print(info.id, info.title, info.model, info.system_prompt, info.history)
Assistant
`