g4f-space / demo /BackendApi.py
roxky's picture
Update README.md
2f323d8
raw
history blame contribute delete
873 Bytes
from __future__ import annotations
from g4f.typing import Messages, AsyncResult
import g4f.Provider
from g4f.Provider import BackendApi
from . import url, headers
BackendApi.working = True
BackendApi.ssl = False
BackendApi.url = url
BackendApi.headers = headers
class BackendApi(BackendApi):
working = True
ssl = False
url = url
headers = headers
image_models = ["flux", "flux-pro"]
models = ["deepseek-r1", *g4f.Provider.OpenaiAccount.get_models(), "flux", "flux-pro"]
@classmethod
async def create_async_generator(
cls,
model: str,
messages: Messages,
**kwargs
) -> AsyncResult:
if model in g4f.Provider.OpenaiAccount.get_models():
kwargs["provider"] = "OpenaiAccount"
async for chunk in super().create_async_generator(model, messages, **kwargs):
yield chunk