summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider')
-rw-r--r--g4f/Provider/__init__.py1
-rw-r--r--g4f/Provider/needs_auth/HuggingChat.py9
2 files changed, 7 insertions, 3 deletions
diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py
index efc94613..bfc02590 100644
--- a/g4f/Provider/__init__.py
+++ b/g4f/Provider/__init__.py
@@ -39,7 +39,6 @@ from .Koala import Koala
from .Liaobots import Liaobots
from .Llama2 import Llama2
from .MyShell import MyShell
-from .NoowAi import NoowAi
from .OnlineGpt import OnlineGpt
from .Opchatgpts import Opchatgpts
from .PerplexityAi import PerplexityAi
diff --git a/g4f/Provider/needs_auth/HuggingChat.py b/g4f/Provider/needs_auth/HuggingChat.py
index 530069c0..41c938b4 100644
--- a/g4f/Provider/needs_auth/HuggingChat.py
+++ b/g4f/Provider/needs_auth/HuggingChat.py
@@ -47,14 +47,19 @@ class HuggingChat(AsyncGeneratorProvider):
"web_search": web_search
}
async with session.post(f"{cls.url}/conversation/{conversation_id}", json=send, proxy=proxy) as response:
+ first_token = True
async for line in response.content:
line = json.loads(line[:-1])
if "type" not in line:
raise RuntimeError(f"Response: {line}")
elif line["type"] == "stream":
- yield line["token"]
+ token = line["token"]
+ if first_token:
+ token = token.lstrip()
+ first_token = False
+ yield token
elif line["type"] == "finalAnswer":
break
async with session.delete(f"{cls.url}/conversation/{conversation_id}", proxy=proxy) as response:
- response.raise_for_status() \ No newline at end of file
+ response.raise_for_status()