Fix HuggingFace formatting

pull/2089/head
abc 3 months ago
parent ac0bd092c0
commit 46c48bb09e

@ -8,7 +8,6 @@ from .helper import format_prompt
import random
class Aichatos(AsyncGeneratorProvider):
url = "https://chat10.aichatos.xyz"
api = "https://api.binjie.fun"

@ -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

Loading…
Cancel
Save