summaryrefslogtreecommitdiffstats
path: root/g4f/gui/webview.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-03-16 18:22:26 +0100
committerGitHub <noreply@github.com>2024-03-16 18:22:26 +0100
commitfb2061da48525edab9cd993205bb5e30c386aa1a (patch)
tree1e740bd6955dfd27b9a4d773df07234ed9e5c75e /g4f/gui/webview.py
parentMerge pull request #1694 from ComRSMaster/main (diff)
parentAdd conversation support for Bing (diff)
downloadgpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar
gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.gz
gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.bz2
gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.lz
gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.xz
gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.zst
gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.zip
Diffstat (limited to '')
-rw-r--r--g4f/gui/webview.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/g4f/gui/webview.py b/g4f/gui/webview.py
index 5a4263dc..a8e745f3 100644
--- a/g4f/gui/webview.py
+++ b/g4f/gui/webview.py
@@ -1,24 +1,37 @@
import webview
-from functools import partial
-from platformdirs import user_config_dir
+try:
+ from platformdirs import user_config_dir
+ has_platformdirs = True
+except ImportError:
+ has_platformdirs = False
-from g4f.gui import run_gui
from g4f.gui.run import gui_parser
+from g4f.gui.server.api import Api
import g4f.version
import g4f.debug
-def run_webview(host: str = "0.0.0.0", port: int = 8080, debug: bool = True):
- webview.create_window(f"g4f - {g4f.version.utils.current_version}", f"http://{host}:{port}/")
- if debug:
- g4f.debug.logging = True
+def run_webview(
+ debug: bool = False,
+ storage_path: str = None
+):
+ webview.create_window(
+ f"g4f - {g4f.version.utils.current_version}",
+ "client/index.html",
+ text_select=True,
+ js_api=Api(),
+ )
+ if has_platformdirs and storage_path is None:
+ storage_path = user_config_dir("g4f-webview")
webview.start(
- partial(run_gui, host, port),
private_mode=False,
- storage_path=user_config_dir("g4f-webview"),
- debug=debug
+ storage_path=storage_path,
+ debug=debug,
+ ssl=True
)
if __name__ == "__main__":
parser = gui_parser()
args = parser.parse_args()
- run_webview(args.host, args.port, args.debug) \ No newline at end of file
+ if args.debug:
+ g4f.debug.logging = True
+ run_webview(args.debug) \ No newline at end of file