Call in your terminal the create_provider
script:
python -m etc.tool.create_provider
cURL
command from your browser developer tools.from __future__ import annotations
from ..typing import AsyncResult, Messages
from .base_provider import AsyncGeneratorProvider
class HogeService(AsyncGeneratorProvider):
url = "https://chat-gpt.com"
working = True
supports_gpt_35_turbo = True
@classmethod
async def create_async_generator(
cls,
model: str,
messages: Messages,
proxy: str = None,
**kwargs
) -> AsyncResult:
yield ""
supports_stream
to True
...create_async_generator
and yield
the response, even if it's a one-time response, do not hesitate to look at other providers for inspiration.g4f/Provider/__init__.py
from .HogeService import HogeService
__all__ = [
HogeService,
]
import g4f
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.PROVIDERNAME,
messages=[{"role": "user", "content": "test"}], stream=g4f.Provider.PROVIDERNAME.supports_stream)
for message in response:
print(message, flush=True, end='')