XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Fix HuggingFace formatting

46c48bb0
abc <98614666+xtekky@users.noreply.github.com>
提交于

代码差异

3 个文件 +43 -41
Modified g4f/Provider/Aichatos.py +0 -1
@@ -8,7 +8,6 @@ from .helper import format_prompt
8 8
9 9 import random
10 10
11
12 11 class Aichatos(AsyncGeneratorProvider):
13 12 url = "https://chat10.aichatos.xyz"
14 13 api = "https://api.binjie.fun"
Modified g4f/Provider/HuggingChat.py +40 -37
@@ -5,7 +5,7 @@ import json, requests, re
5 5 from curl_cffi import requests as cf_reqs
6 6 from ..typing import CreateResult, Messages
7 7 from .base_provider import ProviderModelMixin, AbstractProvider
8 from .helper import format_prompt, get_connector, get_cookies
8 from .helper import format_prompt
9 9
10 10 class HuggingChat(AbstractProvider, ProviderModelMixin):
11 11 url = "https://huggingface.co/chat"
@@ -41,34 +41,34 @@ class HuggingChat(AbstractProvider, ProviderModelMixin):
41 41
42 42 session = requests.Session()
43 43 headers = {
44 'accept': '*/*',
45 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
46 'cache-control': 'no-cache',
47 'origin': 'https://huggingface.co',
48 'pragma': 'no-cache',
49 'priority': 'u=1, i',
50 'referer': 'https://huggingface.co/chat/',
51 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
52 'sec-ch-ua-mobile': '?0',
44 'accept' : '*/*',
45 'accept-language' : 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
46 'cache-control' : 'no-cache',
47 'origin' : 'https://huggingface.co',
48 'pragma' : 'no-cache',
49 'priority' : 'u=1, i',
50 'referer' : 'https://huggingface.co/chat/',
51 'sec-ch-ua' : '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
52 'sec-ch-ua-mobile' : '?0',
53 53 'sec-ch-ua-platform': '"macOS"',
54 'sec-fetch-dest': 'empty',
55 'sec-fetch-mode': 'cors',
56 'sec-fetch-site': 'same-origin',
57 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
54 'sec-fetch-dest' : 'empty',
55 'sec-fetch-mode' : 'cors',
56 'sec-fetch-site' : 'same-origin',
57 'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
58 58 }
59 59
60 60 json_data = {
61 'searchEnabled': True,
62 'ethicsModalAccepted': True,
63 'ethicsModalAcceptedAt': None,
64 'activeModel': 'CohereForAI/c4ai-command-r-plus', # doesn't matter
61 'searchEnabled' : True,
62 'activeModel' : 'CohereForAI/c4ai-command-r-plus', # doesn't matter
65 63 'hideEmojiOnSidebar': False,
64 'customPrompts' : {},
65 'assistants' : [],
66 'tools' : {},
67 'disableStream' : False,
68 'recentlySaved' : False,
69 'ethicsModalAccepted' : True,
70 'ethicsModalAcceptedAt' : None,
66 71 'shareConversationsWithModelAuthors': False,
67 'customPrompts': {},
68 'assistants': [],
69 'tools': {},
70 'disableStream': False,
71 'recentlySaved': False,
72 72 }
73 73
74 74 response = cf_reqs.post('https://huggingface.co/chat/settings', headers=headers, json=json_data)
@@ -85,20 +85,20 @@ class HuggingChat(AbstractProvider, ProviderModelMixin):
85 85 messageId = extract_id(response.json())
86 86
87 87 settings = {
88 "inputs": format_prompt(messages),
89 "id": messageId,
90 "is_retry": False,
91 "is_continue": False,
92 "web_search": False,
88 "inputs" : format_prompt(messages),
89 "id" : messageId,
90 "is_retry" : False,
91 "is_continue" : False,
92 "web_search" : False,
93 93
94 # enable tools
94 # TODO // add feature to enable/disable tools
95 95 "tools": {
96 "websearch": True,
97 "document_parser": False,
98 "query_calculator": False,
99 "image_generation": False,
100 "image_editing": False,
101 "fetch_url": False,
96 "websearch" : True,
97 "document_parser" : False,
98 "query_calculator" : False,
99 "image_generation" : False,
100 "image_editing" : False,
101 "fetch_url" : False,
102 102 }
103 103 }
104 104
@@ -122,8 +122,11 @@ class HuggingChat(AbstractProvider, ProviderModelMixin):
122 122 if first_token:
123 123 token = token.lstrip().replace('\u0000', '')
124 124 first_token = False
125 #yield token
126 yield (token)
125
126 else:
127 token = token.replace('\u0000', '')
128
129 yield token
127 130
128 131 elif line["type"] == "finalAnswer":
129 132 break
Modified g4f/Provider/deprecated/Acytoo.py +3 -3
@@ -7,10 +7,10 @@ from ..base_provider import AsyncGeneratorProvider
7 7
8 8
9 9 class Acytoo(AsyncGeneratorProvider):
10 url = 'https://chat.acytoo.com'
11 working = False
10 url = 'https://chat.acytoo.com'
11 working = False
12 12 supports_message_history = True
13 supports_gpt_35_turbo = True
13 supports_gpt_35_turbo = True
14 14
15 15 @classmethod
16 16 async def create_async_generator(