g4f升级到0.5.2.0版本了,但是有些机器无法运行,只能降级到0.5.1.2版本
g4f升级到0.5.2.0版本了,跟0.5.1.2更以前的版本相比,主要更新为增加了可以设置Huggingface等供应商的key
Providers API key
HuggingFace:Get API key
HuggingSpace:
因为很多模型都会调用Huggingface,所以最好设置Huggingface的API key。还可以设置很多key:
另外,提供了github部署,可以使用这个地址使用:G4F - Framework
新版本运行的时候,跟踪信息里有更多的报错输出,具体见:g4f升级到0.5.2.0报错g4f.errors.MissingRequirementsError: could not find a valid chrome browser binary-CSDN博客
(新版本API和GUI二合一了,也就是1337端口也是GUI端口。因为没调通,所以这里不太确定。好像不是这样,这里并没有变化)
新版本的参数非常多(误以为):
python3.11 -m g4f --help
usage: __main__.py [-h] [--bind BIND] [--port PORT] [--debug] [--gui] [--model MODEL][--provider {ARTA,AllenAI,Anthropic,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,CablyAI,Cerebras,ChatGLM,ChatGptEs,Chatai,CohereForAI_C4AI_Command,Copilot,CopilotAccount,Custom,DDG,DeepInfra,DeepInfraChat,DeepSeek,DeepseekAI_JanusPro7b,Dynaspark,Free2GPT,FreeGpt,FreeRouter,Gemini,GeminiPro,GigaChat,GithubCopilot,GizAI,GlhfChat,Glider,Goabror,Grok,Groq,HailuoAI,HarProvider,HuggingChat,HuggingFace,HuggingFaceAPI,HuggingFaceInference,HuggingFaceMedia,HuggingSpace,ImageLabs,Jmuz,LambdaChat,Liaobots,Local,MetaAI,MetaAIAccount,MicrosoftDesigner,Microsoft_Phi_4,MiniMax,OIVSCode,Ollama,OpenRouter,OpenaiAPI,OpenaiAccount,OpenaiChat,PerplexityApi,PerplexityLabs,Pi,PollinationsAI,PollinationsImage,Qwen_QVQ_72B,Qwen_Qwen_2_5,Qwen_Qwen_2_5M,Qwen_Qwen_2_5_Max,Qwen_Qwen_2_72B,Reka,Replicate,RubiksAI,StabilityAI_SD35Large,TeachAnything,ThebApi,TypeGPT,Voodoohop_Flux1Schnell,Websim,WhiteRabbitNeo,You,Yqcloud,Voodoohop_Flux1Schnell,xAI,AnyProvider}][--media-provider {ARTA,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,DeepseekAI_JanusPro7b,Gemini,HuggingChat,HuggingFaceInference,ImageLabs,MetaAIAccount,MicrosoftDesigner,OpenaiAccount,OpenaiChat,PollinationsAI,PollinationsImage,StabilityAI_SD35Large,TypeGPT,Voodoohop_Flux1Schnell,Websim,You,Voodoohop_Flux1Schnell}][--proxy PROXY] [--workers WORKERS] [--disable-colors] [--ignore-cookie-files][--g4f-api-key G4F_API_KEY][--ignored-providers {ARTA,AllenAI,Anthropic,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,CablyAI,Cerebras,ChatGLM,ChatGptEs,Chatai,CohereForAI_C4AI_Command,Copilot,CopilotAccount,Custom,DDG,DeepInfra,DeepInfraChat,DeepSeek,DeepseekAI_JanusPro7b,Dynaspark,Free2GPT,FreeGpt,FreeRouter,Gemini,GeminiPro,GigaChat,GithubCopilot,GizAI,GlhfChat,Glider,Goabror,Grok,Groq,HailuoAI,HarProvider,HuggingChat,HuggingFace,HuggingFaceAPI,HuggingFaceInference,HuggingFaceMedia,HuggingSpace,ImageLabs,Jmuz,LambdaChat,Liaobots,Local,MetaAI,MetaAIAccount,MicrosoftDesigner,Microsoft_Phi_4,MiniMax,OIVSCode,Ollama,OpenRouter,OpenaiAPI,OpenaiAccount,OpenaiChat,PerplexityApi,PerplexityLabs,Pi,PollinationsAI,PollinationsImage,Qwen_QVQ_72B,Qwen_Qwen_2_5,Qwen_Qwen_2_5M,Qwen_Qwen_2_5_Max,Qwen_Qwen_2_72B,Reka,Replicate,RubiksAI,StabilityAI_SD35Large,TeachAnything,ThebApi,TypeGPT,Voodoohop_Flux1Schnell,Websim,WhiteRabbitNeo,You,Yqcloud,Voodoohop_Flux1Schnell,xAI,AnyProvider} [{ARTA,AllenAI,Anthropic,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,CablyAI,Cerebras,ChatGLM,ChatGptEs,Chatai,CohereForAI_C4AI_Command,Copilot,CopilotAccount,Custom,DDG,DeepInfra,DeepInfraChat,DeepSeek,DeepseekAI_JanusPro7b,Dynaspark,Free2GPT,FreeGpt,FreeRouter,Gemini,GeminiPro,GigaChat,GithubCopilot,GizAI,GlhfChat,Glider,Goabror,Grok,Groq,HailuoAI,HarProvider,HuggingChat,HuggingFace,HuggingFaceAPI,HuggingFaceInference,HuggingFaceMedia,HuggingSpace,ImageLabs,Jmuz,LambdaChat,Liaobots,Local,MetaAI,MetaAIAccount,MicrosoftDesigner,Microsoft_Phi_4,MiniMax,OIVSCode,Ollama,OpenRouter,OpenaiAPI,OpenaiAccount,OpenaiChat,PerplexityApi,PerplexityLabs,Pi,PollinationsAI,PollinationsImage,Qwen_QVQ_72B,Qwen_Qwen_2_5,Qwen_Qwen_2_5M,Qwen_Qwen_2_5_Max,Qwen_Qwen_2_72B,Reka,Replicate,RubiksAI,StabilityAI_SD35Large,TeachAnything,ThebApi,TypeGPT,Voodoohop_Flux1Schnell,Websim,WhiteRabbitNeo,You,Yqcloud,Voodoohop_Flux1Schnell,xAI,AnyProvider} ...]][--cookie-browsers {} [{} ...]] [--reload] [--demo] [--ssl-keyfile SSL_KEYFILE][--ssl-certfile SSL_CERTFILE] [--log-config LOG_CONFIG]Run the API and GUIoptions:-h, --help show this help message and exit--bind BIND The bind string. (Default: 0.0.0.0:1337)--port PORT, -p PORT Change the port of the server.--debug, -d Enable verbose logging.--gui, -g Start also the gui.--model MODEL Default model for chat completion. (incompatible with --reload and --workers)--provider {ARTA,AllenAI,Anthropic,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,CablyAI,Cerebras,ChatGLM,ChatGptEs,Chatai,CohereForAI_C4AI_Command,Copilot,CopilotAccount,Custom,DDG,DeepInfra,DeepInfraChat,DeepSeek,DeepseekAI_JanusPro7b,Dynaspark,Free2GPT,FreeGpt,FreeRouter,Gemini,GeminiPro,GigaChat,GithubCopilot,GizAI,GlhfChat,Glider,Goabror,Grok,Groq,HailuoAI,HarProvider,HuggingChat,HuggingFace,HuggingFaceAPI,HuggingFaceInference,HuggingFaceMedia,HuggingSpace,ImageLabs,Jmuz,LambdaChat,Liaobots,Local,MetaAI,MetaAIAccount,MicrosoftDesigner,Microsoft_Phi_4,MiniMax,OIVSCode,Ollama,OpenRouter,OpenaiAPI,OpenaiAccount,OpenaiChat,PerplexityApi,PerplexityLabs,Pi,PollinationsAI,PollinationsImage,Qwen_QVQ_72B,Qwen_Qwen_2_5,Qwen_Qwen_2_5M,Qwen_Qwen_2_5_Max,Qwen_Qwen_2_72B,Reka,Replicate,RubiksAI,StabilityAI_SD35Large,TeachAnything,ThebApi,TypeGPT,Voodoohop_Flux1Schnell,Websim,WhiteRabbitNeo,You,Yqcloud,Voodoohop_Flux1Schnell,xAI,AnyProvider}Default provider for chat completion. (incompatible with --reload and --workers)--media-provider {ARTA,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,DeepseekAI_JanusPro7b,Gemini,HuggingChat,HuggingFaceInference,ImageLabs,MetaAIAccount,MicrosoftDesigner,OpenaiAccount,OpenaiChat,PollinationsAI,PollinationsImage,StabilityAI_SD35Large,TypeGPT,Voodoohop_Flux1Schnell,Websim,You,Voodoohop_Flux1Schnell}Default provider for image generation. (incompatible with --reload and --workers)--proxy PROXY Default used proxy. (incompatible with --reload and --workers)--workers WORKERS Number of workers.--disable-colors Don't use colors.--ignore-cookie-filesDon't read .har and cookie files. (incompatible with --reload and --workers)--g4f-api-key G4F_API_KEYSets an authentication key for your API. (incompatible with --reload and --workers)--ignored-providers {ARTA,AllenAI,Anthropic,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,CablyAI,Cerebras,ChatGLM,ChatGptEs,Chatai,CohereForAI_C4AI_Command,Copilot,CopilotAccount,Custom,DDG,DeepInfra,DeepInfraChat,DeepSeek,DeepseekAI_JanusPro7b,Dynaspark,Free2GPT,FreeGpt,FreeRouter,Gemini,GeminiPro,GigaChat,GithubCopilot,GizAI,GlhfChat,Glider,Goabror,Grok,Groq,HailuoAI,HarProvider,HuggingChat,HuggingFace,HuggingFaceAPI,HuggingFaceInference,HuggingFaceMedia,HuggingSpace,ImageLabs,Jmuz,LambdaChat,Liaobots,Local,MetaAI,MetaAIAccount,MicrosoftDesigner,Microsoft_Phi_4,MiniMax,OIVSCode,Ollama,OpenRouter,OpenaiAPI,OpenaiAccount,OpenaiChat,PerplexityApi,PerplexityLabs,Pi,PollinationsAI,PollinationsImage,Qwen_QVQ_72B,Qwen_Qwen_2_5,Qwen_Qwen_2_5M,Qwen_Qwen_2_5_Max,Qwen_Qwen_2_72B,Reka,Replicate,RubiksAI,StabilityAI_SD35Large,TeachAnything,ThebApi,TypeGPT,Voodoohop_Flux1Schnell,Websim,WhiteRabbitNeo,You,Yqcloud,Voodoohop_Flux1Schnell,xAI,AnyProvider} [{ARTA,AllenAI,Anthropic,BingCreateImages,BlackForestLabs_Flux1Dev,BlackForestLabs_Flux1Schnell,Blackbox,CablyAI,Cerebras,ChatGLM,ChatGptEs,Chatai,CohereForAI_C4AI_Command,Copilot,CopilotAccount,Custom,DDG,DeepInfra,DeepInfraChat,DeepSeek,DeepseekAI_JanusPro7b,Dynaspark,Free2GPT,FreeGpt,FreeRouter,Gemini,GeminiPro,GigaChat,GithubCopilot,GizAI,GlhfChat,Glider,Goabror,Grok,Groq,HailuoAI,HarProvider,HuggingChat,HuggingFace,HuggingFaceAPI,HuggingFaceInference,HuggingFaceMedia,HuggingSpace,ImageLabs,Jmuz,LambdaChat,Liaobots,Local,MetaAI,MetaAIAccount,MicrosoftDesigner,Microsoft_Phi_4,MiniMax,OIVSCode,Ollama,OpenRouter,OpenaiAPI,OpenaiAccount,OpenaiChat,PerplexityApi,PerplexityLabs,Pi,PollinationsAI,PollinationsImage,Qwen_QVQ_72B,Qwen_Qwen_2_5,Qwen_Qwen_2_5M,Qwen_Qwen_2_5_Max,Qwen_Qwen_2_72B,Reka,Replicate,RubiksAI,StabilityAI_SD35Large,TeachAnything,ThebApi,TypeGPT,Voodoohop_Flux1Schnell,Websim,WhiteRabbitNeo,You,Yqcloud,Voodoohop_Flux1Schnell,xAI,AnyProvider} ...]List of providers to ignore when processing request. (incompatible with --reload and--workers)--cookie-browsers {} [{} ...]List of browsers to access or retrieve cookies from. (incompatible with --reload and--workers)--reload Enable reloading.--demo Enable demo mode.--ssl-keyfile SSL_KEYFILEPath to SSL key file for HTTPS.--ssl-certfile SSL_CERTFILEPath to SSL certificate file for HTTPS.--log-config LOG_CONFIGCustom log config.
有调通的小伙伴,请告知一下哦!
哦哦,不对,其实是因为调用方法不同导致的,其实还是这样的:
g4f --help
usage: g4f [-h] {api,gui} ...Run gpt4freepositional arguments:{api,gui} Mode to run the g4f in.options:-h, --help show this help message and exit
g4f api --help
会有一大堆的参数,就像上面那样。
一台Ubuntu20 安装新版本成功了,
两台ubuntu22都安装新版本不成功
差别在哪里呢?
使用pip list,找不同:
20里有cryptography 43.0.3
pip install cryptography之后
新的报错:
ERROR:g4f.gui.server.app:Exception on /chat/07d7b534-d885-4de5-b80c-50822a7d68f5 [GET]
Traceback (most recent call last):File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1511, in wsgi_appresponse = self.full_dispatch_request()File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 919, in full_dispatch_requestrv = self.handle_user_exception(e)File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 917, in full_dispatch_requestrv = self.dispatch_request()File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 902, in dispatch_requestreturn self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
TypeError: Website._chat() got an unexpected keyword argument 'conversation_id'
192.168.1.2 - - [29/Apr/2025 13:15:39] "GET /chat/07d7b534-d885-4de5-b80c-50822a7d68f5 HTTP/1.1" 500 -
发现duckduckgo_search这个库版本不一样
成功的是8.0.1,失败的是2025.4.4 。换成8.0.1版本
pip install duckduckgo_search==8.0.1
还是报错:
ERROR:g4f.gui.server.app:Exception on / [GET]
Traceback (most recent call last):File "/usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py", line 787, in urlopenresponse = self._make_request(File "/usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py", line 488, in _make_requestraise new_eFile "/usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py", line 464, in _make_requestself._validate_conn(conn)File "/usr/local/lib/python3.10/dist-packages/urllib3/connectionpool.py", line 1093, in _validate_connconn.connect()File "/usr/local/lib/python3.10/dist-packages/urllib3/connection.py", line 741, in connectsock_and_verified = _ssl_wrap_socket_and_match_hostname(File "/usr/local/lib/python3.10/dist-packages/urllib3/connection.py", line 920, in _ssl_wrap_socket_and_match_hostnamessl_sock = ssl_wrap_socket(File "/usr/local/lib/python3.10/dist-packages/urllib3/util/ssl_.py", line 460, in ssl_wrap_socketssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)File "/usr/local/lib/python3.10/dist-packages/urllib3/util/ssl_.py", line 504, in _ssl_wrap_socket_implreturn ssl_context.wrap_socket(sock, server_hostname=server_hostname)File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socketreturn self.sslsocket_class._create(File "/usr/lib/python3.10/ssl.py", line 1100, in _createself.do_handshake()File "/usr/lib/python3.10/ssl.py", line 1371, in do_handshakeself._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer
发现python3.10的没成功
到python3.11环境下,升级g4f试试
不行
把urllib3降低版本到2.3.0
python3.11 -m pip install urllib3==2.3.0
不行
也就是不是python版本的问题。
最终还是无法让0.5.2.0版本正确运行,不得已安装了0.5.1.2版本才行。