Merge pull request #1240 from hlohaus/pi

Add auto_continue to OpenaiChat
pull/1243/head
Tekky 11 months ago committed by GitHub
commit df8f41645c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -371,73 +371,67 @@ if __name__ == "__main__":
``` ```
## 🚀 Providers and Models ## 🚀 Providers and Models
### GPT-4 ### GPT-4
| Website| Provider| gpt-3.5 | gpt-4 | Stream | Async | Status | Auth |
| ------ | ------- | ------- | ----- | --------- | --------- | ------ | ---- | | Website | Provider | GPT-3.5 | GPT-4 | Stream | Status | Auth |
| [bing.com](https://bing.com/chat) | `g4f.Provider.Bing` | ❌ | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | ------ | ------- | ------- | ----- | ------ | ------ | ---- |
| [chat.geekgpt.org](https://chat.geekgpt.org) | `g4f.Provider.GeekGpt` | ✔️ | ✔️ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [bing.com](https://bing.com/chat) | `g4f.Provider.Bing` | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [liaobots.site](https://liaobots.site) | `g4f.Provider.Liaobots` | ✔️ | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chat.geekgpt.org](https://chat.geekgpt.org) | `g4f.Provider.GeekGpt` | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [www.phind.com](https://www.phind.com) | `g4f.Provider.Phind` | ❌ | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [gptchatly.com](https://gptchatly.com) | `g4f.Provider.GptChatly` | ✔️ | ✔️ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [raycast.com](https://raycast.com) | `g4f.Provider.Raycast` | ✔️ | ✔️ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ | | [liaobots.site](https://liaobots.site) | `g4f.Provider.Liaobots` | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chat.aivvm.com](https://chat.aivvm.com) | `g4f.Provider.Aivvm` | ✔️ | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [www.phind.com](https://www.phind.com) | `g4f.Provider.Phind` | ❌ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [gptchatly.com](https://gptchatly.com) | `g4f.Provider.GptChatly` | ✔️ | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [raycast.com](https://raycast.com) | `g4f.Provider.Raycast` | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
| [supertest.lockchat.app](http://supertest.lockchat.app) | `g4f.Provider.Lockchat` | ✔️ | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [app.myshell.ai](https://app.myshell.ai/chat) | `g4f.Provider.Myshell` | ✔️ | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
### GPT-3.5 ### GPT-3.5
| Website| Provider| gpt-3.5 | Stream | Async | Status | Auth | | Website | Provider | GPT-3.5 | GPT-4 | Stream | Status | Auth |
| ------ | ------- | ------- | --------- | --------- | ------ | ---- | | ------ | ------- | ------- | ----- | ------ | ------ | ---- |
| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | `g4f.Provider.Yqcloud` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [www.aitianhu.com](https://www.aitianhu.com) | `g4f.Provider.AItianhu` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [www.aitianhu.com](https://www.aitianhu.com) | `g4f.Provider.AItianhu` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chat3.aiyunos.top](https://chat3.aiyunos.top/) | `g4f.Provider.AItianhuSpace` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chat3.aiyunos.top](https://chat3.aiyunos.top/) | `g4f.Provider.AItianhuSpace` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [e.aiask.me](https://e.aiask.me) | `g4f.Provider.AiAsk` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [e.aiask.me](https://e.aiask.me) | `g4f.Provider.AiAsk` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chat-gpt.org](https://chat-gpt.org/chat) | `g4f.Provider.Aichat` | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chat-gpt.org](https://chat-gpt.org/chat) | `g4f.Provider.Aichat` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [www.chatbase.co](https://www.chatbase.co) | `g4f.Provider.ChatBase` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [www.chatbase.co](https://www.chatbase.co) | `g4f.Provider.ChatBase` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chatforai.store](https://chatforai.store) | `g4f.Provider.ChatForAi` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chatgpt.ai](https://chatgpt.ai/) | `g4f.Provider.ChatgptAi` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chatgpt.ai](https://chatgpt.ai) | `g4f.Provider.ChatgptAi` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [chatgptfree.ai](https://chatgptfree.ai) | `g4f.Provider.ChatgptFree` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chatgptx.de](https://chatgptx.de) | `g4f.Provider.ChatgptX` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chatgptx.de](https://chatgptx.de) | `g4f.Provider.ChatgptX` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chat-shared2.zhile.io](https://chat-shared2.zhile.io) | `g4f.Provider.FakeGpt` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [freegpts1.aifree.site](https://freegpts1.aifree.site/) | `g4f.Provider.FreeGpt` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [freegpts1.aifree.site](https://freegpts1.aifree.site/) | `g4f.Provider.FreeGpt` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [gptalk.net](https://gptalk.net) | `g4f.Provider.GPTalk` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [gptalk.net](https://gptalk.net) | `g4f.Provider.GPTalk` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [ai18.gptforlove.com](https://ai18.gptforlove.com) | `g4f.Provider.GptForLove` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [ai18.gptforlove.com](https://ai18.gptforlove.com) | `g4f.Provider.GptForLove` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [gptgo.ai](https://gptgo.ai) | `g4f.Provider.GptGo` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [gptgo.ai](https://gptgo.ai) | `g4f.Provider.GptGo` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [www.llama2.ai](https://www.llama2.ai) | `g4f.Provider.Llama2` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [hashnode.com](https://hashnode.com) | `g4f.Provider.Hashnode` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [noowai.com](https://noowai.com) | `g4f.Provider.NoowAi` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [app.myshell.ai](https://app.myshell.ai/chat) | `g4f.Provider.MyShell` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chat.openai.com](https://chat.openai.com) | `g4f.Provider.OpenaiChat` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ | | [noowai.com](https://noowai.com) | `g4f.Provider.NoowAi` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [theb.ai](https://theb.ai) | `g4f.Provider.Theb` | ✔️ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ | | [chat.openai.com](https://chat.openai.com) | `g4f.Provider.OpenaiChat` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
| [sdk.vercel.ai](https://sdk.vercel.ai) | `g4f.Provider.Vercel` | ✔️ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [theb.ai](https://theb.ai) | `g4f.Provider.Theb` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
| [you.com](https://you.com) | `g4f.Provider.You` | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [sdk.vercel.ai](https://sdk.vercel.ai) | `g4f.Provider.Vercel` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [chat.acytoo.com](https://chat.acytoo.com) | `g4f.Provider.Acytoo` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [you.com](https://you.com) | `g4f.Provider.You` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [aiservice.vercel.app](https://aiservice.vercel.app/) | `g4f.Provider.AiService` | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | `g4f.Provider.Yqcloud` | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [aibn.cc](https://aibn.cc) | `g4f.Provider.Aibn` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chat.acytoo.com](https://chat.acytoo.com) | `g4f.Provider.Acytoo` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [ai.ls](https://ai.ls) | `g4f.Provider.Ails` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [aibn.cc](https://aibn.cc) | `g4f.Provider.Aibn` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chataigpt.org](https://chataigpt.org) | `g4f.Provider.ChatAiGpt` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [ai.ls](https://ai.ls) | `g4f.Provider.Ails` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chatforai.store](https://chatforai.store) | `g4f.Provider.ChatForAi` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chatgpt4online.org](https://chatgpt4online.org) | `g4f.Provider.Chatgpt4Online` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chatgpt4online.org](https://chatgpt4online.org) | `g4f.Provider.Chatgpt4Online` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chat.chatgptdemo.net](https://chat.chatgptdemo.net) | `g4f.Provider.ChatgptDemo` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chat.chatgptdemo.net](https://chat.chatgptdemo.net) | `g4f.Provider.ChatgptDemo` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chatgptduo.com](https://chatgptduo.com) | `g4f.Provider.ChatgptDuo` | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chatgptduo.com](https://chatgptduo.com) | `g4f.Provider.ChatgptDuo` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chatgptfree.ai](https://chatgptfree.ai) | `g4f.Provider.ChatgptFree` | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chatgptlogin.ai](https://chatgptlogin.ai) | `g4f.Provider.ChatgptLogin` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chatgptlogin.ai](https://chatgptlogin.ai) | `g4f.Provider.ChatgptLogin` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [ava-ai-ef611.web.app](https://ava-ai-ef611.web.app) | `g4f.Provider.CodeLinkAva` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [cromicle.top](https://cromicle.top) | `g4f.Provider.Cromicle` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [cromicle.top](https://cromicle.top) | `g4f.Provider.Cromicle` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [gptgod.site](https://gptgod.site) | `g4f.Provider.GptGod` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chat.dfehub.com](https://chat.dfehub.com/) | `g4f.Provider.DfeHub` | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [opchatgpts.net](https://opchatgpts.net) | `g4f.Provider.Opchatgpts` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [free.easychat.work](https://free.easychat.work) | `g4f.Provider.EasyChat` | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chat.ylokh.xyz](https://chat.ylokh.xyz) | `g4f.Provider.Ylokh` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [next.eqing.tech](https://next.eqing.tech/) | `g4f.Provider.Equing` | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chat9.fastgpt.me](https://chat9.fastgpt.me/) | `g4f.Provider.FastGpt` | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | ### Other
| [forefront.com](https://forefront.com) | `g4f.Provider.Forefront` | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chat.getgpt.world](https://chat.getgpt.world/) | `g4f.Provider.GetGpt` | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | Website | Provider | GPT-3.5 | GPT-4 | Stream | Status | Auth |
| [gptgod.site](https://gptgod.site) | `g4f.Provider.GptGod` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | ------ | ------- | ------- | ----- | ------ | ------ | ---- |
| [komo.ai](https://komo.ai/api/ask) | `g4f.Provider.Komo` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [bard.google.com](https://bard.google.com) | `g4f.Provider.Bard` | ❌ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
| [ai.okmiku.com](https://ai.okmiku.com) | `g4f.Provider.MikuChat` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [deepinfra.com](https://deepinfra.com) | `g4f.Provider.DeepInfra` | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
| [opchatgpts.net](https://opchatgpts.net) | `g4f.Provider.Opchatgpts` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [huggingface.co](https://huggingface.co/chat) | `g4f.Provider.HuggingChat` | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
| [www.perplexity.ai](https://www.perplexity.ai) | `g4f.Provider.PerplexityAi` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [www.llama2.ai](https://www.llama2.ai) | `g4f.Provider.Llama2` | ❌ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
| [talkai.info](https://talkai.info) | `g4f.Provider.TalkAi` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [open-assistant.io](https://open-assistant.io/chat) | `g4f.Provider.OpenAssistant` | ❌ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ✔️ |
| [p5.v50.ltd](https://p5.v50.ltd) | `g4f.Provider.V50` | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [app.vitalentum.io](https://app.vitalentum.io) | `g4f.Provider.Vitalentum` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | ### Models
| [wewordle.org](https://wewordle.org) | `g4f.Provider.Wewordle` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chat.wuguokai.xyz](https://chat.wuguokai.xyz) | `g4f.Provider.Wuguokai` | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [chat.ylokh.xyz](https://chat.ylokh.xyz) | `g4f.Provider.Ylokh` | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
### Other Models
| Model | Base Provider | Provider | Website | | Model | Base Provider | Provider | Website |
| --------------------------------------- | ------------- | ------------------- | ------------------------------------------- | | --------------------------------------- | ------------- | ------------------- | ------------------------------------------- |

@ -35,8 +35,14 @@ def main():
def get_providers() -> list[type[BaseProvider]]: def get_providers() -> list[type[BaseProvider]]:
providers = dir(Provider) providers = dir(Provider)
providers = [getattr(Provider, provider) for provider in providers if provider != "RetryProvider"] providers = [getattr(Provider, provider) for provider in providers if provider != "RetryProvider"]
providers = [provider for provider in providers if isinstance(provider, type)] providers = [provider for provider in providers if isinstance(provider, type) and hasattr(provider, "url")]
return [provider for provider in providers if issubclass(provider, BaseProvider)] return [
provider
for provider in providers
if issubclass(provider, BaseProvider)
and provider.__name__ not in dir(Provider.deprecated)
and provider.__name__ not in dir(Provider.unfinished)
]
def create_response(_provider: type[BaseProvider]) -> str: def create_response(_provider: type[BaseProvider]) -> str:

@ -3,58 +3,32 @@ import sys
from pathlib import Path from pathlib import Path
from urllib.parse import urlparse from urllib.parse import urlparse
sys.path.append(str(Path(__file__).parent.parent)) sys.path.append(str(Path(__file__).parent.parent.parent))
import asyncio import asyncio
from g4f import models from g4f import models
from g4f.Provider.base_provider import AsyncProvider, BaseProvider from g4f import ChatCompletion
from g4f.Provider.retry_provider import RetryProvider from g4f.Provider.base_provider import BaseProvider
from testing._providers import get_providers from etc.testing._providers import get_providers
logging = False from g4f import debug
debug.logging = True
def print_imports():
print("##### Providers:")
print("```py")
print("from g4f.Provider import (")
for _provider in get_providers():
if _provider.working:
print(f" {_provider.__name__},")
print(")")
print("# Usage:")
print("response = g4f.ChatCompletion.create(..., provider=ProviderName)")
print("```")
print()
print()
def print_async():
print("##### Async support:")
print("```py")
print("_providers = [")
for _provider in get_providers():
if _provider.working and issubclass(_provider, AsyncProvider):
print(f" g4f.Provider.{_provider.__name__},")
print("]")
print("```")
print()
print()
async def test_async(provider: type[BaseProvider]): async def test_async(provider: type[BaseProvider]):
if not provider.working: if not provider.working:
return False return False
model = models.gpt_35_turbo.name if provider.supports_gpt_35_turbo else models.default.name
messages = [{"role": "user", "content": "Hello Assistant!"}] messages = [{"role": "user", "content": "Hello Assistant!"}]
try: try:
if issubclass(provider, AsyncProvider): response = await asyncio.wait_for(ChatCompletion.create_async(
response = await provider.create_async(model=model, messages=messages) model=models.default,
else: messages=messages,
response = provider.create_completion(model=model, messages=messages, stream=False) provider=provider
), 30)
return bool(response) return bool(response)
except Exception as e: except Exception as e:
if logging: if debug.logging:
print(f"{provider.__name__}: {e.__class__.__name__}: {e}") print(f"{provider.__name__}: {e.__class__.__name__}: {e}")
return False return False
@ -68,44 +42,53 @@ async def test_async_list(providers: list[type[BaseProvider]]):
def print_providers(): def print_providers():
lines = [
"| Website| Provider| gpt-3.5 | gpt-4 | Streaming | Asynchron | Status | Auth |",
"| ------ | ------- | ------- | ----- | --------- | --------- | ------ | ---- |",
]
providers = get_providers() providers = get_providers()
responses = asyncio.run(test_async_list(providers)) responses = asyncio.run(test_async_list(providers))
for is_working in (True, False): for type in ("GPT-4", "GPT-3.5", "Other"):
for idx, _provider in enumerate(providers): lines = [
if is_working != _provider.working: "",
continue f"### {type}",
if _provider == RetryProvider: "",
continue "| Website | Provider | GPT-3.5 | GPT-4 | Stream | Status | Auth |",
"| ------ | ------- | ------- | ----- | ------ | ------ | ---- |",
netloc = urlparse(_provider.url).netloc ]
website = f"[{netloc}]({_provider.url})" for is_working in (True, False):
for idx, _provider in enumerate(providers):
provider_name = f"`g4f.Provider.{_provider.__name__}`" if is_working != _provider.working:
continue
has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else "" do_continue = False
has_gpt_4 = "✔️" if _provider.supports_gpt_4 else "" if type == "GPT-4" and _provider.supports_gpt_4:
stream = "✔️" if _provider.supports_stream else "" do_continue = True
can_async = "✔️" if issubclass(_provider, AsyncProvider) else "" elif type == "GPT-3.5" and not _provider.supports_gpt_4 and _provider.supports_gpt_35_turbo:
if _provider.working: do_continue = True
status = '![Active](https://img.shields.io/badge/Active-brightgreen)' elif type == "Other" and not _provider.supports_gpt_4 and not _provider.supports_gpt_35_turbo:
if responses[idx]: do_continue = True
if not do_continue:
continue
netloc = urlparse(_provider.url).netloc
website = f"[{netloc}]({_provider.url})"
provider_name = f"`g4f.Provider.{_provider.__name__}`"
has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else ""
has_gpt_4 = "✔️" if _provider.supports_gpt_4 else ""
stream = "✔️" if _provider.supports_stream else ""
if _provider.working:
status = '![Active](https://img.shields.io/badge/Active-brightgreen)' status = '![Active](https://img.shields.io/badge/Active-brightgreen)'
if responses[idx]:
status = '![Active](https://img.shields.io/badge/Active-brightgreen)'
else:
status = '![Unknown](https://img.shields.io/badge/Unknown-grey)'
else: else:
status = '![Unknown](https://img.shields.io/badge/Unknown-grey)' status = '![Inactive](https://img.shields.io/badge/Inactive-red)'
else: auth = "✔️" if _provider.needs_auth else ""
status = '![Inactive](https://img.shields.io/badge/Inactive-red)'
auth = "✔️" if _provider.needs_auth else "" lines.append(
f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {status} | {auth} |"
lines.append( )
f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {can_async} | {status} | {auth} |" print("\n".join(lines))
)
print("\n".join(lines))
def print_models(): def print_models():
base_provider_names = { base_provider_names = {
@ -151,8 +134,6 @@ def get_models():
if __name__ == "__main__": if __name__ == "__main__":
print_imports()
print_async()
print_providers() print_providers()
print("\n", "-" * 50, "\n") print("\n", "-" * 50, "\n")
print_models() print_models()

@ -10,6 +10,7 @@ from .helper import format_prompt
class MyShell(AsyncGeneratorProvider): class MyShell(AsyncGeneratorProvider):
url = "https://app.myshell.ai/chat" url = "https://app.myshell.ai/chat"
working = True working = True
supports_gpt_35_turbo = True
@classmethod @classmethod
async def create_async_generator( async def create_async_generator(

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
import uuid, json, time, os import uuid, json, time, asyncio
from py_arkose_generator.arkose import get_values_for_request from py_arkose_generator.arkose import get_values_for_request
from ..base_provider import AsyncGeneratorProvider from ..base_provider import AsyncGeneratorProvider
@ -24,6 +24,7 @@ class OpenaiChat(AsyncGeneratorProvider):
proxy: str = None, proxy: str = None,
timeout: int = 120, timeout: int = 120,
access_token: str = None, access_token: str = None,
auto_continue: bool = False,
cookies: dict = None, cookies: dict = None,
**kwargs **kwargs
) -> AsyncResult: ) -> AsyncResult:
@ -34,50 +35,73 @@ class OpenaiChat(AsyncGeneratorProvider):
"Accept": "text/event-stream", "Accept": "text/event-stream",
"Authorization": f"Bearer {access_token}", "Authorization": f"Bearer {access_token}",
} }
async with StreamSession( messages = [
proxies=proxies, {
headers=headers, "id": str(uuid.uuid4()),
impersonate="chrome107", "author": {"role": "user"},
timeout=timeout "content": {"content_type": "text", "parts": [format_prompt(messages)]},
) as session: },
messages = [ ]
{ message_id = str(uuid.uuid4())
"id": str(uuid.uuid4()), data = {
"author": {"role": "user"}, "action": "next",
"content": {"content_type": "text", "parts": [format_prompt(messages)]}, "arkose_token": await get_arkose_token(proxy),
}, "messages": messages,
] "conversation_id": None,
data = { "parent_message_id": message_id,
"action": "next", "model": "text-davinci-002-render-sha",
"arkose_token": await get_arkose_token(proxy), "history_and_training_disabled": not auto_continue,
"messages": messages, }
"conversation_id": None, conversation_id = None
"parent_message_id": str(uuid.uuid4()), while not end_turn:
"model": "text-davinci-002-render-sha", if not auto_continue:
"history_and_training_disabled": True, end_turn = True
} async with StreamSession(
async with session.post(f"{cls.url}/backend-api/conversation", json=data) as response: proxies=proxies,
response.raise_for_status() headers=headers,
last_message = "" impersonate="chrome107",
async for line in response.iter_lines(): timeout=timeout
if line.startswith(b"data: "): ) as session:
line = line[6:] async with session.post(f"{cls.url}/backend-api/conversation", json=data) as response:
if line == b"[DONE]": try:
break response.raise_for_status()
try: except:
line = json.loads(line) raise RuntimeError(f"Response: {await response.text()}")
except: last_message = ""
continue async for line in response.iter_lines():
if "message" not in line: if line.startswith(b"data: "):
continue line = line[6:]
if "error" in line and line["error"]: if line == b"[DONE]":
raise RuntimeError(line["error"]) break
if "message_type" not in line["message"]["metadata"]: try:
continue line = json.loads(line)
if line["message"]["metadata"]["message_type"] == "next": except:
new_message = line["message"]["content"]["parts"][0] continue
yield new_message[len(last_message):] if "message" not in line:
last_message = new_message continue
if "error" in line and line["error"]:
raise RuntimeError(line["error"])
end_turn = line["message"]["end_turn"]
message_id = line["message"]["id"]
if line["conversation_id"]:
conversation_id = line["conversation_id"]
if "message_type" not in line["message"]["metadata"]:
continue
if line["message"]["metadata"]["message_type"] in ("next", "continue"):
new_message = line["message"]["content"]["parts"][0]
yield new_message[len(last_message):]
last_message = new_message
if end_turn:
return
data = {
"action": "continue",
"arkose_token": await get_arkose_token(proxy),
"conversation_id": conversation_id,
"parent_message_id": message_id,
"model": "text-davinci-002-render-sha",
"history_and_training_disabled": False,
}
await asyncio.sleep(5)
@classmethod @classmethod
async def browse_access_token(cls) -> str: async def browse_access_token(cls) -> str:

@ -82,7 +82,7 @@ llama2_7b = Model(
best_provider = RetryProvider([Llama2, DeepInfra])) best_provider = RetryProvider([Llama2, DeepInfra]))
llama2_13b = Model( llama2_13b = Model(
name ="meta-llama/Llama-2-13b-chat-hf", name = "meta-llama/Llama-2-13b-chat-hf",
base_provider = 'huggingface', base_provider = 'huggingface',
best_provider = RetryProvider([Llama2, DeepInfra])) best_provider = RetryProvider([Llama2, DeepInfra]))

@ -21,4 +21,4 @@ asgiref
fastapi fastapi
uvicorn uvicorn
flask flask
git+https://github.com/hlohaus/py-arkose-token-generator.git py-arkose-generator
Loading…
Cancel
Save