Package: ai4f
AI 4 FREEBy using this repository or any code related to it, you agree to thelegal notice. The author is not responsible for any copies, forks, or reuploads made by other users. This is the author's only account and repository. To prevent impersonation or irresponsible actions, you may comply with the GNU GPL license this Repository uses.This (quite censored) New Version of gpt4free, was just released, it may contain bugs, open an issue or contribute a PR when encountering one, some features were disabled.
Docker is for now not available but I would be happy if someone contributes a PR. The g4f GUI will be uploaded soon enough.Newpypi package:pip install -U ai4fTable of Contents:Getting StartedPrerequisitesSetting up the projectUsageTheg4fPackageinterference openai-proxy apiModelsgpt-3.5 / gpt-4Other ModelsRelated gpt4free projectsContributeChatGPT cloneCopyrightCopyright NoticeStar HistoryGetting StartedPrerequisites:Download and install Python(Version 3.x is recommended).Setting up the project:Install using pypipip install -U ai4forClone the GitHub repository:git clone https://github.com/hansfzlorenzana/AI-4-Free.gitNavigate to the project directory:cd AI-4-Free(Recommended) Create a virtual environment to manage Python packages for your project:python3 -m venv venvActivate the virtual environment:On Windows:.\venv\Scripts\activateOn macOS and Linux:source venv/bin/activateInstall the required Python packages fromrequirements.txt:pip install -r requirements.txtCreate atest.pyfile in the root folder and start using the repo, further Instructions are belowimportai4f...UsageTheai4fPackageimportai4fprint(ai4f.Provider.Ails.params)# supported args# Automatic selection of provider# streamed completionresponse=ai4f.ChatCompletion.create(model='gpt-3.5-turbo',messages=[{"role":"user","content":"Hello world"}],stream=True)formessageinresponse:print(message)# normal responseresponse=ai4f.ChatCompletion.create(model=ai4f.models.gpt_4,messages=[{"role":"user","content":"hi"}])# alterative model settingprint(response)# Set with providerresponse=ai4f.ChatCompletion.create(model='gpt-3.5-turbo',provider=ai4f.Provider.Forefront,messages=[{"role":"user","content":"Hello world"}],stream=True)formessageinresponse:print(message)providers:fromai4f.Providerimport(Ails,You,Bing,Yqcloud,Theb,Aichat,Bard,Vercel,Forefront,Lockchat,Liaobots,H2o,ChatgptLogin,DeepAi,GetGpt,AItianhu,EasyChat,Acytoo,DfeHub,AiService,BingHuan,Wewordle,ChatgptAi,opchatgpts,Poe,)# usage:response=ai4f.ChatCompletion.create(...,provider=ProviderName)interference openai-proxy api (use with openai python package)run server:python3-minterference.appimportopenaiopenai.api_key=''openai.api_base='http://127.0.0.1:1337'chat_completion=openai.ChatCompletion.create(stream=True,model='gpt-3.5-turbo',messages=[{'role':'user','content':'write a poem about a tree'}])#print(chat_completion.choices[0].message.content)fortokeninchat_completion:content=token['choices'][0]['delta'].get('content')ifcontent!=None:print(content)Modelsgpt-3.5 / gpt-4WebsiteProvidergpt-3.5gpt-4othersStreamStatusAuthai.lsg4f.Provider.Ails✔️❌❌✔️❌you.comg4f.Provider.You✔️❌❌✔️❌bing.comg4f.Provider.Bing❌✔️❌✔️❌chat9.yqcloud.topg4f.Provider.Yqcloud✔️❌❌✔️❌theb.aig4f.Provider.Theb✔️❌❌✔️❌chat-gpt.orgg4f.Provider.Aichat✔️❌❌❌❌bard.google.comg4f.Provider.Bard❌❌✔️❌✔️play.vercel.aig4f.Provider.Vercel✔️❌✔️✔️❌forefront.comg4f.Provider.Forefront✔️❌❌✔️❌supertest.lockchat.appg4f.Provider.Lockchat✔️✔️❌✔️❌liaobots.comg4f.Provider.Liaobots✔️✔️❌✔️✔️gpt-gm.h2o.aig4f.Provider.H2o❌❌✔️✔️❌chatgptlogin.acg4f.Provider.ChatgptLogin✔️❌❌❌❌deepai.orgg4f.Provider.DeepAi✔️❌❌✔️❌chat.getgpt.worldg4f.Provider.GetGpt✔️❌❌✔️❌www.aitianhu.comg4f.Provider.AItianhu✔️❌❌❌❌free.easychat.workg4f.Provider.EasyChat✔️❌❌✔️❌chat.acytoo.comg4f.Provider.Acytoo✔️❌❌❌❌chat.dfehub.comg4f.Provider.DfeHub✔️❌❌✔️❌aiservice.vercel.appg4f.Provider.AiService✔️❌❌❌❌b.ai-huan.xyzg4f.Provider.BingHuan✔️✔️❌✔️❌wewordle.orgg4f.Provider.Wewordle✔️❌❌❌❌chatgpt.aig4f.Provider.ChatgptAi❌✔️❌❌❌opchatgpts.netg4f.Provider.opchatgpts✔️❌❌❌❌poe.comg4f.Provider.Poe✔️✔️✔️✔️✔️Other ModelsModelBase ProviderProviderWebsitepalm2Googleg4f.Provider.BardGoogle Bardsage-assistantQuorag4f.Provider.PoeQuora Poeclaude-instant-v1-100kAnthropicg4f.Provider.PoeQuora Poeclaude-v2-100kAnthropicg4f.Provider.PoeQuora Poeclaude-instant-v1Anthropicg4f.Provider.PoeQuora Poegpt-3.5-turbo-16kOpenAIg4f.Provider.PoeQuora Poegpt-4-32kOpenAIg4f.Provider.PoeQuora Poellama-2-7bMeta AIg4f.Provider.PoeQuora Poellama-2-13bMeta AIg4f.Provider.PoeQuora Poellama-2-70bMeta AIg4f.Provider.PoeQuora Poefalcon-40bHuggingfaceg4f.Provider.H2oH2ofalcon-7bHuggingfaceg4f.Provider.H2oH2ollama-13bHuggingfaceg4f.Provider.H2oH2oclaude-instant-v1-100kAnthropicg4f.Provider.Vercelsdk.vercel.aiclaude-instant-v1Anthropicg4f.Provider.Vercelsdk.vercel.aiclaude-v1-100kAnthropicg4f.Provider.Vercelsdk.vercel.aiclaude-v1Anthropicg4f.Provider.Vercelsdk.vercel.aialpaca-7bReplicateg4f.Provider.Vercelsdk.vercel.aistablelm-tuned-alpha-7bReplicateg4f.Provider.Vercelsdk.vercel.aibloomHuggingfaceg4f.Provider.Vercelsdk.vercel.aibloomzHuggingfaceg4f.Provider.Vercelsdk.vercel.aiflan-t5-xxlHuggingfaceg4f.Provider.Vercelsdk.vercel.aiflan-ul2Huggingfaceg4f.Provider.Vercelsdk.vercel.aigpt-neox-20bHuggingfaceg4f.Provider.Vercelsdk.vercel.aioasst-sft-4-pythia-12b-epoch-3.5Huggingfaceg4f.Provider.Vercelsdk.vercel.aisantacoderHuggingfaceg4f.Provider.Vercelsdk.vercel.aicommand-medium-nightlyCohereg4f.Provider.Vercelsdk.vercel.aicommand-xlarge-nightlyCohereg4f.Provider.Vercelsdk.vercel.aicode-cushman-001OpenAIg4f.Provider.Vercelsdk.vercel.aicode-davinci-002OpenAIg4f.Provider.Vercelsdk.vercel.aitext-ada-001OpenAIg4f.Provider.Vercelsdk.vercel.aitext-babbage-001OpenAIg4f.Provider.Vercelsdk.vercel.aitext-curie-001OpenAIg4f.Provider.Vercelsdk.vercel.aitext-davinci-002OpenAIg4f.Provider.Vercelsdk.vercel.aitext-davinci-003OpenAIg4f.Provider.Vercelsdk.vercel.aiRelated AI-4Free projects🎁 Projects⭐ Stars📚 Forks🛎 Issues📬 Pull requestsgpt4freefreeGPTPoe API WrapperEdge GPTBard ReversedChatGPT ReversedPython Poe APIContributeto add another provider, its very simple:create a new file inai4f/Provider/Providerswith the name of the Providerin the file, paste theBoilerplateyou can find inai4f/Provider/Provider.py:importosfrom..typingimportsha256,Dict,get_type_hintsurl=Nonemodel=Nonesupports_stream=Falseneeds_auth=Falsedef_create_completion(model:str,messages:list,stream:bool,**kwargs):returnparams=f'ai4f.Providers.{os.path.basename(__file__)[:-3]}supports: '+\'(%s)'%', '.join([f"{name}:{get_type_hints(_create_completion)[name].__name__}"fornamein_create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])Here, you can adjust the settings, for example if the website does support streaming, setsupports_streamtoTrue...Write code to request the provider in_create_completionandyieldthe response,even ifits a one-time response, do not hesitate to look at other providers for inspirationAdd the Provider Name inai4f/Provider/init.pyfrom.importProviderfrom.Providersimport(...,ProviderNameHere)You are done !, test the provider by calling it:importai4fresponse=ai4f.ChatCompletion.create(model='gpt-3.5-turbo',provider=ai4f.Provider.PROVIDERNAME,messages=[{"role":"user","content":"test"}],stream=g4f.Provider.PROVIDERNAME.supports_stream)formessageinresponse:print(message,flush=True,end='')Copyright:This program is licensed under theGNU GPL v3Copyright Notice:hansfzlorenzana/AI-4-Free: Copyright (C) 2023 hansfzlorenzana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.Star History