|
|
|
@ -5,7 +5,7 @@ import json, requests, re
|
|
|
|
|
from curl_cffi import requests as cf_reqs
|
|
|
|
|
from ..typing import CreateResult, Messages
|
|
|
|
|
from .base_provider import ProviderModelMixin, AbstractProvider
|
|
|
|
|
from .helper import format_prompt, get_connector, get_cookies
|
|
|
|
|
from .helper import format_prompt
|
|
|
|
|
|
|
|
|
|
class HuggingChat(AbstractProvider, ProviderModelMixin):
|
|
|
|
|
url = "https://huggingface.co/chat"
|
|
|
|
@ -59,16 +59,16 @@ class HuggingChat(AbstractProvider, ProviderModelMixin):
|
|
|
|
|
|
|
|
|
|
json_data = {
|
|
|
|
|
'searchEnabled' : True,
|
|
|
|
|
'ethicsModalAccepted': True,
|
|
|
|
|
'ethicsModalAcceptedAt': None,
|
|
|
|
|
'activeModel' : 'CohereForAI/c4ai-command-r-plus', # doesn't matter
|
|
|
|
|
'hideEmojiOnSidebar': False,
|
|
|
|
|
'shareConversationsWithModelAuthors': False,
|
|
|
|
|
'customPrompts' : {},
|
|
|
|
|
'assistants' : [],
|
|
|
|
|
'tools' : {},
|
|
|
|
|
'disableStream' : False,
|
|
|
|
|
'recentlySaved' : False,
|
|
|
|
|
'ethicsModalAccepted' : True,
|
|
|
|
|
'ethicsModalAcceptedAt' : None,
|
|
|
|
|
'shareConversationsWithModelAuthors': False,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response = cf_reqs.post('https://huggingface.co/chat/settings', headers=headers, json=json_data)
|
|
|
|
@ -91,7 +91,7 @@ class HuggingChat(AbstractProvider, ProviderModelMixin):
|
|
|
|
|
"is_continue" : False,
|
|
|
|
|
"web_search" : False,
|
|
|
|
|
|
|
|
|
|
# enable tools
|
|
|
|
|
# TODO // add feature to enable/disable tools
|
|
|
|
|
"tools": {
|
|
|
|
|
"websearch" : True,
|
|
|
|
|
"document_parser" : False,
|
|
|
|
@ -122,8 +122,11 @@ class HuggingChat(AbstractProvider, ProviderModelMixin):
|
|
|
|
|
if first_token:
|
|
|
|
|
token = token.lstrip().replace('\u0000', '')
|
|
|
|
|
first_token = False
|
|
|
|
|
#yield token
|
|
|
|
|
yield (token)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
token = token.replace('\u0000', '')
|
|
|
|
|
|
|
|
|
|
yield token
|
|
|
|
|
|
|
|
|
|
elif line["type"] == "finalAnswer":
|
|
|
|
|
break
|
|
|
|
|