From bbb858249bc055819aad331cff326fa9a722b578 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Tue, 17 Dec 2024 21:17:40 +0100 Subject: Improve gradient in gui, show only models with enabled providers (#2492) - **Cloudflare Provider**: Added error handling for missing requirements when fetching arguments. - **Copilot Provider**: Updated the prompt formatting to use a maximum length function, improving message handling. - **PollinationsAI Provider**: Adjusted the prompt length to a maximum of 5000 characters. - **GitHub Copilot Provider**: Updated to use `ClientSession` for better session management. - **CSS Updates**: Enhanced the gradient styling in the GUI for a more visually appealing interface. - **JavaScript Updates**: Added functionality to toggle search options in the chat interface. --- g4f/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'g4f/__init__.py') diff --git a/g4f/__init__.py b/g4f/__init__.py index ef3cf23a..7d8da231 100644 --- a/g4f/__init__.py +++ b/g4f/__init__.py @@ -42,7 +42,9 @@ class ChatCompletion: if "proxy" not in kwargs: proxy = os.environ.get("G4F_PROXY") if proxy: - kwargs['proxy'] = proxy + kwargs["proxy"] = proxy + if ignore_stream: + kwargs["ignore_stream"] = True result = provider.create_completion(model, messages, stream=stream, **kwargs) @@ -53,9 +55,20 @@ class ChatCompletion: messages : Messages, provider : Union[ProviderType, str, None] = None, stream : bool = False, + image : ImageType = None, + image_name: Optional[str] = None, + ignore_stream: bool = False, ignore_working: bool = False, **kwargs) -> Union[AsyncResult, Coroutine[str]]: model, provider = get_model_and_provider(model, provider, False, ignore_working) + if image is not None: + kwargs["images"] = [(image, image_name)] + if "proxy" not in kwargs: + proxy = os.environ.get("G4F_PROXY") + if proxy: + kwargs["proxy"] = proxy + if ignore_stream: + kwargs["ignore_stream"] = True if stream: if hasattr(provider, "create_async_generator"): -- cgit v1.2.3