XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Refactor Api class to remove unused base_url configuration and update proxy handling in iter_run_tools

7989874f
hlohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

5 个文件 +3 -9
Modified g4f/api/__init__.py +0 -2
@@ -474,8 +474,6 @@ class Api:
474 474 config.stream_timeout = AppConfig.stream_timeout
475 475 if credentials is not None and credentials.credentials != "secret":
476 476 config.api_key = credentials.credentials
477 if AppConfig.disable_custom_base_url:
478 config.base_url = None
479 477
480 478 conversation = config.conversation
481 479 if conversation:
Modified g4f/api/stubs.py +0 -3
@@ -18,9 +18,7 @@ class RequestConfig(BaseModel):
18 18 max_tokens: Optional[int] = None
19 19 stop: Union[list[str], str, None] = None
20 20 api_key: Optional[Union[str, dict[str, str]]] = None
21 base_url: Optional[str] = None
22 21 web_search: Optional[bool] = None
23 proxy: Optional[str] = None
24 22 conversation: Optional[dict] = None
25 23 timeout: Optional[int] = None
26 24 stream_timeout: Optional[int] = None
@@ -82,7 +80,6 @@ class ImageGenerationConfig(BaseModel):
82 80 provider: Optional[str] = None
83 81 response_format: Optional[str] = None
84 82 api_key: Optional[str] = None
85 proxy: Optional[str] = None
86 83 width: Optional[int] = None
87 84 height: Optional[int] = None
88 85 num_inference_steps: Optional[int] = None
Modified g4f/client/types.py +2 -1
@@ -4,6 +4,7 @@ import os
4 4
5 5 from .stubs import ChatCompletion, ChatCompletionChunk
6 6 from ..providers.types import BaseProvider
7 from ..config import AppConfig
7 8 from typing import Union, Iterator, AsyncIterator
8 9
9 10 Proxies = Union[dict, str]
@@ -27,7 +28,7 @@ class Client():
27 28 if isinstance(self.proxies, str):
28 29 return self.proxies
29 30 elif self.proxies is None:
30 return os.environ.get("G4F_PROXY")
31 return AppConfig.proxy
31 32 elif "all" in self.proxies:
32 33 return self.proxies["all"]
33 34 elif "https" in self.proxies:
Modified g4f/config.py +0 -2
@@ -47,7 +47,6 @@ class AppConfig:
47 47 timeout: int = DEFAULT_TIMEOUT
48 48 stream_timeout: int = DEFAULT_STREAM_TIMEOUT
49 49 disable_custom_api_key: bool = False
50 disable_custom_base_url: bool = False
51 50
52 51 @classmethod
53 52 def set_config(cls, **data):
@@ -63,5 +62,4 @@ class AppConfig:
63 62 cls.proxy = os.environ.get("G4F_PROXY", cls.proxy)
64 63 cls.model = os.environ.get("G4F_MODEL", cls.model)
65 64 cls.provider = os.environ.get("G4F_PROVIDER", cls.provider)
66 cls.disable_custom_base_url = os.environ.get("G4F_DISABLE_CUSTOM_BASE_URL", str(cls.disable_custom_base_url)).lower() in ("true", "1", "yes")
67 65 cls.disable_custom_api_key = os.environ.get("G4F_DISABLE_CUSTOM_API_KEY", str(cls.disable_custom_api_key)).lower() in ("true", "1", "yes")
Modified g4f/gui/server/api.py +1 -1
@@ -205,7 +205,7 @@ class Api:
205 205 if hasattr(provider_handler, "get_parameters"):
206 206 yield self._format_json("parameters", provider_handler.get_parameters(as_json=True))
207 207 try:
208 result = iter_run_tools(provider_handler, **{**kwargs, "model": model, "download_media": download_media})
208 result = iter_run_tools(provider_handler, **{**kwargs, "model": model, "download_media": download_media, "proxy": proxy})
209 209 for chunk in result:
210 210 if isinstance(chunk, ProviderInfo):
211 211 model = getattr(chunk, "model", model)