Skip to content

Commit

Permalink
Add ignored-providers argument to gui
Browse files Browse the repository at this point in the history
  • Loading branch information
hlohaus committed Jan 3, 2025
1 parent 1b30651 commit b0bc665
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion g4f/gui/client/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
<script>
const iframe = document.getElementById('stream-widget');
iframe.src = iframe.dataset.src + navigator.language;
setTimeout(()=>iframe.classList.add('show'), 5000);
setTimeout(()=>iframe.classList.add('show'), 3000);

(async () => {
const prompt = `
Expand Down
3 changes: 3 additions & 0 deletions g4f/gui/gui_parser.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from argparse import ArgumentParser

from ..cookies import browsers
from .. import Provider

def gui_parser():
parser = ArgumentParser(description="Run the GUI")
parser.add_argument("--host", type=str, default="0.0.0.0", help="hostname")
parser.add_argument("--port", "-p", type=int, default=8080, help="port")
parser.add_argument("--debug", "-d", "-debug", action="store_true", help="debug mode")
parser.add_argument("--ignore-cookie-files", action="store_true", help="Don't read .har and cookie files.")
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 --reload and --workers)")
parser.add_argument("--cookie-browsers", nargs="+", choices=[browser.__name__ for browser in browsers],
default=[], help="List of browsers to access or retrieve cookies from.")
return parser
9 changes: 8 additions & 1 deletion g4f/gui/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from .gui_parser import gui_parser
from ..cookies import read_cookie_files
from g4f.gui import run_gui
from ..gui import run_gui
from ..Provider import ProviderUtils

import g4f.cookies
import g4f.debug

Expand All @@ -13,6 +15,11 @@ def run_gui_args(args):
port = args.port
debug = args.debug
g4f.cookies.browsers = [g4f.cookies[browser] for browser in args.cookie_browsers]
if args.ignored_providers:
for provider in args.ignored_providers:
if provider in ProviderUtils.convert:
ProviderUtils.convert[provider].working = False

run_gui(host, port, debug)

if __name__ == "__main__":
Expand Down

0 comments on commit b0bc665

Please sign in to comment.