From 6ce493d4dfc2884832ff5b5be4479a55818b2fe7 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Sat, 16 Nov 2024 13:19:51 +0100 Subject: Fix api streaming, fix AsyncClient (#2357) * Fix api streaming, fix AsyncClient, Improve Client class, Some providers fixes, Update models list, Fix some tests, Update model list in Airforce provid er, Add OpenAi image generation url to api, Fix reload and debug in api arguments, Fix websearch in gui * Fix Cloadflare and Pi and AmigoChat provider * Fix conversation support in DDG provider, Add cloudflare bypass with nodriver * Fix unittests without curl_cffi --- g4f/Provider/HuggingChat.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'g4f/Provider/HuggingChat.py') diff --git a/g4f/Provider/HuggingChat.py b/g4f/Provider/HuggingChat.py index d4a4b497..509a7f16 100644 --- a/g4f/Provider/HuggingChat.py +++ b/g4f/Provider/HuggingChat.py @@ -3,8 +3,13 @@ from __future__ import annotations import json import requests -from curl_cffi import requests as cf_reqs +try: + from curl_cffi import requests as cf_reqs + has_curl_cffi = True +except ImportError: + has_curl_cffi = False from ..typing import CreateResult, Messages +from ..errors import MissingRequirementsError from .base_provider import ProviderModelMixin, AbstractProvider from .helper import format_prompt @@ -55,6 +60,8 @@ class HuggingChat(AbstractProvider, ProviderModelMixin): stream: bool, **kwargs ) -> CreateResult: + if not has_curl_cffi: + raise MissingRequirementsError('Install "curl_cffi" package | pip install -U curl_cffi') model = cls.get_model(model) if model in cls.models: -- cgit v1.2.3