mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
feat: add model alias handling and update Cloudflare provider
- Introduced `clean_name` function in `Cloudflare.py` to format model names by removing specific suffixes. - Updated `model_aliases` in `Cloudflare` class with new model mappings, and cleaned up redundant entries. - Set `models` in the `Cloudflare` class to use keys from `model_aliases`. - Adjusted the caching logic in `Cloudflare` to include new headers for requests. - Added `parent` and `login_url` attributes in `DeepInfraChat` class. - Updated `PollinationsAI` to clean up model retrieval logic and fixed handling of existing checks. - Refactored `HarProvider` to inherit models and aliases from `LegacyLMArena`. - Implemented loading environment variables from `.env` file in `cookies.py`. - Updated default headers in `defaults.py` for user agent and `sec-ch-ua`. - Cleaned up various model references in `any_model_map.py` to reflect differences in audio, vision, and other model types. - Added a more centralized handling for API key management in `run_tools.py` to accommodate new nomenclature. - Enhanced existing logic to allow for more granular loading and utilization of API keys from environment variables.
This commit is contained in:
parent
bdc356c4c2
commit
51b4b8bcb3
19 changed files with 1281 additions and 1041 deletions
|
|
@ -49,7 +49,7 @@ from . import debug
|
|||
|
||||
class CookiesConfig():
|
||||
cookies: Dict[str, Cookies] = {}
|
||||
cookies_dir: str = CUSTOM_COOKIES_DIR if os.path.exists(CUSTOM_COOKIES_DIR) else COOKIES_DIR
|
||||
cookies_dir: str = CUSTOM_COOKIES_DIR if os.path.exists(CUSTOM_COOKIES_DIR) else str(COOKIES_DIR)
|
||||
|
||||
DOMAINS = [
|
||||
".bing.com",
|
||||
|
|
@ -135,6 +135,13 @@ def read_cookie_files(dirPath: str = None):
|
|||
debug.log(f"Read cookies: {dirPath} dir is not readable")
|
||||
return
|
||||
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(os.path.join(dirPath, ".env"), override=True)
|
||||
debug.log(f"Read cookies: Loaded environment variables from {dirPath}/.env")
|
||||
except ImportError:
|
||||
debug.error("Warning: 'python-dotenv' is not installed. Environment variables will not be loaded.")
|
||||
|
||||
def get_domain(v: dict) -> str:
|
||||
host = [h["value"] for h in v['request']['headers'] if h["name"].lower() in ("host", ":authority")]
|
||||
if not host:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue