summaryrefslogtreecommitdiffstats
path: root/g4f/cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/cli.py')
-rw-r--r--g4f/cli.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/g4f/cli.py b/g4f/cli.py
index 9037a6f1..fe219b38 100644
--- a/g4f/cli.py
+++ b/g4f/cli.py
@@ -4,8 +4,6 @@ import argparse
from g4f import Provider
from g4f.gui.run import gui_parser, run_gui_args
-from g4f.cookies import read_cookie_files
-from g4f import debug
def main():
parser = argparse.ArgumentParser(description="Run gpt4free")
@@ -16,9 +14,9 @@ def main():
api_parser.add_argument("--workers", type=int, default=None, help="Number of workers.")
api_parser.add_argument("--disable-colors", action="store_true", help="Don't use colors.")
api_parser.add_argument("--ignore-cookie-files", action="store_true", help="Don't read .har and cookie files.")
- api_parser.add_argument("--g4f-api-key", type=str, default=None, help="Sets an authentication key for your API.")
- api_parser.add_argument("--ignored-providers", nargs="+", choices=[provider for provider in Provider.__map__],
- default=[], help="List of providers to ignore when processing request.")
+ api_parser.add_argument("--g4f-api-key", type=str, default=None, help="Sets an authentication key for your API. (incompatible with --debug and --workers)")
+ api_parser.add_argument("--ignored-providers", nargs="+", choices=[provider.__name__ for provider in Provider.__providers__ if provider.working],
+ default=[], help="List of providers to ignore when processing request. (incompatible with --debug and --workers)")
subparsers.add_parser("gui", parents=[gui_parser()], add_help=False)
args = parser.parse_args()
@@ -31,19 +29,21 @@ def main():
exit(1)
def run_api_args(args):
- if args.debug:
- debug.logging = True
- if not args.ignore_cookie_files:
- read_cookie_files()
- import g4f.api
- g4f.api.set_list_ignored_providers(
+ from g4f.api import AppConfig, run_api
+
+ AppConfig.set_ignore_cookie_files(
+ args.ignore_cookie_files
+ )
+ AppConfig.set_list_ignored_providers(
args.ignored_providers
)
- g4f.api.run_api(
+ AppConfig.set_g4f_api_key(
+ args.g4f_api_key
+ )
+ run_api(
bind=args.bind,
debug=args.debug,
workers=args.workers,
- g4f_api_key=args.g4f_api_key,
use_colors=not args.disable_colors
)