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/api/stubs.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 g4f/api/stubs.py (limited to 'g4f/api/stubs.py') diff --git a/g4f/api/stubs.py b/g4f/api/stubs.py new file mode 100644 index 00000000..8610f6b0 --- /dev/null +++ b/g4f/api/stubs.py @@ -0,0 +1,63 @@ +from __future__ import annotations + +from pydantic import BaseModel, Field +from typing import Union, Optional + +from g4f.typing import Messages + +class ChatCompletionsConfig(BaseModel): + messages: Messages = Field(examples=[[{"role": "system", "content": ""}, {"role": "user", "content": ""}]]) + model: str = Field(default="") + provider: Optional[str] = None + stream: bool = False + image: Optional[str] = None + image_name: Optional[str] = None + images: Optional[list[tuple[str, str]]] = None + temperature: Optional[float] = None + max_tokens: Optional[int] = None + stop: Union[list[str], str, None] = None + api_key: Optional[str] = None + web_search: Optional[bool] = None + proxy: Optional[str] = None + conversation_id: Optional[str] = None + history_disabled: Optional[bool] = None + auto_continue: Optional[bool] = None + timeout: Optional[int] = None + +class ImageGenerationConfig(BaseModel): + prompt: str + model: Optional[str] = None + provider: Optional[str] = None + response_format: Optional[str] = None + api_key: Optional[str] = None + proxy: Optional[str] = None + +class ProviderResponseModel(BaseModel): + id: str + object: str = "provider" + created: int + url: Optional[str] + label: Optional[str] + +class ProviderResponseDetailModel(ProviderResponseModel): + models: list[str] + image_models: list[str] + vision_models: list[str] + params: list[str] + +class ModelResponseModel(BaseModel): + id: str + object: str = "model" + created: int + owned_by: Optional[str] + +class ErrorResponseModel(BaseModel): + error: ErrorResponseMessageModel + model: Optional[str] = None + provider: Optional[str] = None + +class ErrorResponseMessageModel(BaseModel): + message: str + +class FileResponseModel(BaseModel): + filename: str \ No newline at end of file -- cgit v1.2.3