XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Readme: Create Provider with AI Tool

7a699c8c
Heiner Lohaus <heiner@lohaus.eu>
提交于

代码差异

1 个文件 +28 -16
Modified README.md +28 -16
@@ -521,38 +521,50 @@ if __name__ == "__main__":
521 521
522 522 ## Contribute
523 523
524 to add another provider, its very simple:
524 ####Create Provider with AI Tool
525
526 Call in your terminal the "create_provider" script:
527 ```bash
528 $ python etc/tool/create_provider.py
529 ```
530 1. Enter your name for the new provider.
531 2. Copy&Paste cURL command from your browser developer tools.
532 3. Let the AI ​​create the provider for you.
533 4. Customize the provider according to your needs.
534
535 ####Create Provider
525 536
526 537 0. Check out the current [list of potential providers](https://github.com/zukixa/cool-ai-stuff#ai-chat-websites), or find your own provider source!
527 538 1. Create a new file in [g4f/provider](./g4f/provider) with the name of the Provider
528 539 2. Implement a class that extends [BaseProvider](./g4f/provider/base_provider.py).
529 540
530 541 ```py
531 from .base_provider import BaseProvider
532 from ..typing import CreateResult, Any
542 from __future__ import annotations
533 543
544 from ..typing import AsyncResult, Messages
545 from .base_provider import AsyncGeneratorProvider
534 546
535 class HogeService(BaseProvider):
536 url = "http://hoge.com"
537 working = True
547 class HogeService(AsyncGeneratorProvider):
548 url = "https://chat-gpt.com"
538 549 supports_gpt_35_turbo = True
550 working = True
539 551
540 @staticmethod
541 def create_completion(
552 @classmethod
553 async def create_async_generator(
554 cls,
542 555 model: str,
543 messages: list[dict[str, str]],
544 stream: bool,
545 **kwargs: Any,
546 ) -> CreateResult:
547 pass
556 messages: Messages,
557 proxy: str = None,
558 **kwargs
559 ) -> AsyncResult:
560 yield ""
548 561 ```
549 562
550 3. Here, you can adjust the settings, for example if the website does support streaming, set `working` to `True`...
551 4. Write code to request the provider in `create_completion` and `yield` the response, _even if_ its a one-time response, do not hesitate to look at other providers for inspiration
563 3. Here, you can adjust the settings, for example if the website does support streaming, set `supports_stream` to `True`...
564 4. Write code to request the provider in `create_async_generator` and `yield` the response, _even if_ its a one-time response, do not hesitate to look at other providers for inspiration
552 565 5. Add the Provider Name in [g4f/provider/**init**.py](./g4f/provider/__init__.py)
553 566
554 567 ```py
555 from .base_provider import BaseProvider
556 568 from .HogeService import HogeService
557 569
558 570 __all__ = [