Create Provider with AI Tool Call in your terminal the createprovider script: python -m…
- User
Create Provider with AI Tool Call in your terminal the create_provider script:
python -m etc.tool.create_provider Enter your name for the new provider. Copy and paste the cURL command from your browser developer tools. Let the AI create the provider for you. Customize the provider according to your needs. Create Provider Check out the current list of potential providers, or find your own provider source! Create a new file in g4f/Provider with the name of the Provider. Implement a class that extends BaseProvider. 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
code@classmethod async def create_async_generator( cls, model: str, messages: Messages, proxy: str = None, **kwargs ) -> AsyncResult: yield ""Here, you can adjust the settings, for example, if the website does support streaming, set supports_stream to True... Write code to request the provider in 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. Add the Provider Import in g4f/Provider/init.py from .HogeService import HogeService
all = [ HogeService, ] You are done !, test the provider by calling it: 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='')
啥意思
- Assistant
This guide describes how to create a new provider for a given AI tool, specifically for a framework or system that uses a plugin architecture to extend functionality with new service providers. Here's a breakdown of the steps involved:
-
Launch Script: You begin by executing a command in your terminal to start creating a provider. This involves invoking a specific Python module, .
-