Skip to content

Commit

Permalink
refactor(g4f/Provider/HuggingChat.py): Move HuggingChat to needs_auth…
Browse files Browse the repository at this point in the history
… directory

Request by @TheFirstNoob
  • Loading branch information
kqlio67 committed Dec 3, 2024
1 parent e5022b3 commit 7075f86
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion g4f/Provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from .Free2GPT import Free2GPT
from .FreeGpt import FreeGpt
from .GizAI import GizAI
from .HuggingChat import HuggingChat
from .Liaobots import Liaobots
from .MagickPen import MagickPen
from .PerplexityLabs import PerplexityLabs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
has_curl_cffi = True
except ImportError:
has_curl_cffi = False
from ..typing import CreateResult, Messages
from ..errors import MissingRequirementsError
from ..requests.raise_for_status import raise_for_status
from .base_provider import ProviderModelMixin, AbstractProvider
from .helper import format_prompt
from ...typing import CreateResult, Messages
from ...errors import MissingRequirementsError
from ...requests.raise_for_status import raise_for_status
from ..base_provider import ProviderModelMixin, AbstractProvider
from ..helper import format_prompt

class HuggingChat(AbstractProvider, ProviderModelMixin):
url = "https://huggingface.co/chat"
working = True
supports_stream = True
needs_auth = True
default_model = "meta-llama/Meta-Llama-3.1-70B-Instruct"

models = [
Expand Down
4 changes: 2 additions & 2 deletions g4f/Provider/needs_auth/HuggingFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ...errors import ModelNotFoundError
from ...requests import StreamSession, raise_for_status

from ..HuggingChat import HuggingChat
from .HuggingChat import HuggingChat

class HuggingFace(AsyncGeneratorProvider, ProviderModelMixin):
url = "https://huggingface.co/chat"
Expand Down Expand Up @@ -88,4 +88,4 @@ def format_prompt(messages: Messages) -> str:
for idx, message in enumerate(messages)
if message["role"] == "assistant"
])
return f"{history}<s>[INST] {question} [/INST]"
return f"{history}<s>[INST] {question} [/INST]"
4 changes: 2 additions & 2 deletions g4f/Provider/needs_auth/HuggingFace2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from .OpenaiAPI import OpenaiAPI
from ..HuggingChat import HuggingChat
from .HuggingChat import HuggingChat
from ...typing import AsyncResult, Messages

class HuggingFace2(OpenaiAPI):
Expand All @@ -25,4 +25,4 @@ def create_async_generator(
) -> AsyncResult:
return super().create_async_generator(
model, messages, api_base=api_base, max_tokens=max_tokens, **kwargs
)
)
3 changes: 2 additions & 1 deletion g4f/Provider/needs_auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .GeminiPro import GeminiPro
from .GithubCopilot import GithubCopilot
from .Groq import Groq
from .HuggingChat import HuggingChat
from .HuggingFace import HuggingFace
from .HuggingFace2 import HuggingFace2
from .MetaAI import MetaAI
Expand All @@ -24,4 +25,4 @@
from .Replicate import Replicate
from .Theb import Theb
from .ThebApi import ThebApi
from .WhiteRabbitNeo import WhiteRabbitNeo
from .WhiteRabbitNeo import WhiteRabbitNeo

0 comments on commit 7075f86

Please sign in to comment.