summaryrefslogtreecommitdiffstats
path: root/g4f/cli.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-23 14:53:48 +0200
committerGitHub <noreply@github.com>2023-10-23 14:53:48 +0200
commitaa95d30732211877166535096b6eb6310d21283e (patch)
tree9beddcdd73e6ddc0ae999e07f14c03d7b4fe5c5c /g4f/cli.py
parentMerge pull request #1126 from Luneye/patch-3 (diff)
parentMerge branch 'main' into api-ignore-providers (diff)
downloadgpt4free-aa95d30732211877166535096b6eb6310d21283e.tar
gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.gz
gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.bz2
gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.lz
gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.xz
gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.zst
gpt4free-aa95d30732211877166535096b6eb6310d21283e.zip
Diffstat (limited to 'g4f/cli.py')
-rw-r--r--g4f/cli.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/g4f/cli.py b/g4f/cli.py
index 3dbe10b7..cb19dde1 100644
--- a/g4f/cli.py
+++ b/g4f/cli.py
@@ -1,5 +1,8 @@
import argparse
+from enum import Enum
+
import g4f
+from g4f import Provider
from g4f.api import Api
from g4f.gui.run import gui_parser, run_gui_args
@@ -10,14 +13,22 @@ def run_gui(args):
def main():
+ IgnoredProviders = Enum("ignore_providers", {key: key for key in Provider.__all__})
parser = argparse.ArgumentParser(description="Run gpt4free")
subparsers = parser.add_subparsers(dest="mode", help="Mode to run the g4f in.")
- subparsers.add_parser("api")
+ api_parser=subparsers.add_parser("api")
+ api_parser.add_argument("--bind", default="127.0.0.1:1337", help="The bind string.")
+ api_parser.add_argument("--debug", type=bool, default=False, help="Enable verbose logging")
+ api_parser.add_argument("--num-threads", type=int, default=8, help="The number of threads.")
+ api_parser.add_argument("--ignored-providers", nargs="+", choices=[provider.name for provider in IgnoredProviders],
+ default=[], help="List of providers to ignore when processing request.")
subparsers.add_parser("gui", parents=[gui_parser()], add_help=False)
args = parser.parse_args()
if args.mode == "api":
- Api(g4f).run('127.0.0.1:1337', 8)
+ controller=Api(g4f, debug=args.debug)
+ controller.list_ignored_providers=args.ignored_providers
+ controller.run(args.bind, args.num_threads)
elif args.mode == "gui":
run_gui_args(args)
else: