FujiwaraChoki / MoneyPrinterV2

Automate the process of making money online.
GNU Affero General Public License v3.0
2.23k stars 302 forks source link

Need to switch providers #68

Closed Judimax closed 2 months ago

Judimax commented 3 months ago

Greetings I get this error I tried looking around in the g4f docs on how to swithch providers to no avail


Traceback (most recent call last):
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\src\main.py", line 364, in <module>
    main()
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\src\main.py", line 101, in main    
    youtube.generate_video(tts)
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\src\classes\YouTube.py", line 520, in generate_video
    self.generate_topic()
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\src\classes\YouTube.py", line 143, in generate_topic
    completion = self.generate_response(f"Please generate a specific video idea that takes about the following topic: {self.niche}. Make it exactly one sentence. Only return the topic, nothing else.")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\src\classes\YouTube.py", line 116, in gein gein generate_response
    return g4f.ChatCompletion.create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\venv\Lib\site-packages\g4f\__init__.py", line 146, in create
    return result if stream else ''.join([str(chunk) for chunk in result])
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\venv\Lib\site-packages\g4f\__init__.py", line 146, in <listcomp>
    return result if stream else ''.join([str(chunk) for chunk in result])
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\venv\Lib\site-packages\g4f\providers\retry_provider.py", line 81, in create_completion
    raise_exceptions(exceptions)
  File "C:\Users\Restop-1294\My_Apps\Windmillcode_app_tutorials\tutorials\money_printer\MoneyPrinterV2\venv\Lib\site-packages\g4f\providers\retry_provider.py", line 201, in raise_exceptions
    raise RetryProviderError("RetryProvider failed:\n" + "\n".join([
g4f.errors.RetryProviderError: RetryProvider failed:
Bing: RuntimeError: CaptchaChallenge: Use other cookies or/and ip address
Liaobots: ResponseStatusError: Response 401: {"message":"401 Unauthorized"}```
donburgareli commented 3 months ago

Technically this question should be asked in the g4f repository, but since I'm here...

If you are using g4f api and want to specify a provider, here's two ways:

  1. Console Command

Remove from this command the provider you want to use.

g4f api --debug DEBUG --ignored-providers AItianhu AItianhuSpace Acytoo AiAsk AiChatOnline AiChatting AiService Aibn Aichat Ails Aivvm AsyncGeneratorProvider AsyncProvider Aura Bard BaseProvider Berlin Bestim Bing ChatAiGpt ChatAnywhere ChatBase ChatForAi Chatgpt4Online ChatgptAi ChatgptDemo ChatgptDemoAi OpenaiChat ChatgptDuo ChatgptFree ChatgptLogin ChatgptNext ChatgptX Chatxyz CodeLinkAva CreateImagesProvider Cromicle DeepInfra DfeHub EasyChat Equing FakeGpt FastGpt Forefront FreeChatgpt FreeGpt GPTalk GeekGpt Gemini GetGpt Gpt6 GptChatly GptForLove GptGo GptGod GptTalkRu H2o Hashnode HuggingChat Koala Komo Liaobots Llama2 Lockchat MikuChat MyShell Myshell OnlineGpt Opchatgpts OpenAssistant PerplexityAi PerplexityLabs Phind Pi Poe Raycast RetryProvider TalkAi Theb ThebApi V50 Vercel Vitalentum Wewordle Wuguokai Ylokh You Yqcloud

  1. Request Param

Add {"provider": "Provider"} to your request body

e.g:

from openai import OpenAI

client = OpenAI(
    api_key="asdf",
    base_url="http://localhost:1337/v1"
)

response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    extra_body={"provider": "You"},
    messages=[{"role": "user", "content": "write a poem about a tree"}],
)
print(response.choices[0].message.content)

For more info, check https://github.com/xtekky/gpt4free/issues/1584