diff options
Diffstat (limited to '')
-rw-r--r-- | g4f/gui/__init__.py | 6 | ||||
-rw-r--r-- | g4f/gui/client/js/chat.v1.js | 14 | ||||
-rw-r--r-- | g4f/gui/server/backend.py | 4 |
3 files changed, 14 insertions, 10 deletions
diff --git a/g4f/gui/__init__.py b/g4f/gui/__init__.py index d2dfbbc5..46b4f56a 100644 --- a/g4f/gui/__init__.py +++ b/g4f/gui/__init__.py @@ -1,12 +1,12 @@ +from ..errors import MissingRequirementsError try: from .server.app import app from .server.website import Website from .server.backend import Backend_Api except ImportError: - from g4f.errors import MissingRequirementsError - raise MissingRequirementsError('Install "flask" and "werkzeug" package for gui') + raise MissingRequirementsError('Install "flask" package for the gui') -def run_gui(host: str = '0.0.0.0', port: int = 80, debug: bool = False) -> None: +def run_gui(host: str = '0.0.0.0', port: int = 8080, debug: bool = False) -> None: config = { 'host' : host, 'port' : port, diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js index d62c040b..99a75569 100644 --- a/g4f/gui/client/js/chat.v1.js +++ b/g4f/gui/client/js/chat.v1.js @@ -164,12 +164,16 @@ const ask_gpt = async () => { for (const line of value.split("\n")) { if (!line) continue; const message = JSON.parse(line); - if (message["type"] == "content") { - text += message["content"]; + if (message.type == "content") { + text += message.content; } else if (message["type"] == "provider") { - provider = message["provider"]; - content.querySelector('.provider').innerHTML = - '<a href="' + provider.url + '" target="_blank">' + provider.name + "</a>" + provider = message.provider + content.querySelector('.provider').innerHTML = ` + <a href="${provider.url}" target="_blank"> + ${provider.name} + </a> + ${provider.model ? ' with ' + provider.model : ''} + ` } else if (message["type"] == "error") { error = message["error"]; } else if (message["type"] == "message") { diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py index 9346f489..8bf58e52 100644 --- a/g4f/gui/server/backend.py +++ b/g4f/gui/server/backend.py @@ -3,7 +3,7 @@ import json from flask import request, Flask from typing import Generator from g4f import version, models -from g4f import _all_models, get_last_provider, ChatCompletion +from g4f import get_last_provider, ChatCompletion from g4f.image import is_allowed_extension, to_image from g4f.errors import VersionNotFoundError from g4f.Provider import __providers__ @@ -76,7 +76,7 @@ class Backend_Api: Returns: List[str]: A list of model names. """ - return _all_models + return models._all_models def get_providers(self): """ |