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/Provider/Copilot.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'g4f/Provider/Copilot.py') diff --git a/g4f/Provider/Copilot.py b/g4f/Provider/Copilot.py index 4451bbec..e76322da 100644 --- a/g4f/Provider/Copilot.py +++ b/g4f/Provider/Copilot.py @@ -18,7 +18,7 @@ except ImportError: has_nodriver = False from .base_provider import AbstractProvider, ProviderModelMixin, BaseConversation -from .helper import format_prompt +from .helper import format_prompt_max_length from ..typing import CreateResult, Messages, ImagesType from ..errors import MissingRequirementsError, NoValidHarFileError from ..requests.raise_for_status import raise_for_status @@ -120,16 +120,7 @@ class Copilot(AbstractProvider, ProviderModelMixin): conversation_id = response.json().get("id") if return_conversation: yield Conversation(conversation_id) - prompt = format_prompt(messages) - if len(prompt) > 10000: - if len(messages) > 6: - prompt = format_prompt(messages[:3] + messages[-3:]) - if len(prompt) > 10000: - if len(messages) > 2: - prompt = format_prompt(messages[:2] + messages[-1:]) - if len(prompt) > 10000: - prompt = messages[-1]["content"] - debug.log(f"Copilot: Trim messages to: {len(prompt)}") + prompt = format_prompt_max_length(messages, 10000) debug.log(f"Copilot: Created conversation: {conversation_id}") else: conversation_id = conversation.conversation_id -- cgit v1.2.3