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

XFEstudio/gpt4free

Track live model instances in Ollama and Cohere providers, updating count on model retrieval

6607c82d
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +14 -1
Modified g4f/Provider/local/Ollama.py +4 -0
@@ -32,6 +32,8 @@ class Ollama(OpenaiAPI):
32 32 api_key = AuthManager.load_api_key(cls)
33 33 if api_key:
34 34 models = requests.get("https://ollama.com/api/tags", {"headers": {"Authorization": f"Bearer {api_key}"}}).json()["models"]
35 if models:
36 cls.live += 1
35 37 cls.models = [model["name"] for model in models]
36 38 if api_base is None:
37 39 host = os.getenv("OLLAMA_HOST", "127.0.0.1")
@@ -43,6 +45,8 @@ class Ollama(OpenaiAPI):
43 45 models = requests.get(url).json()["models"]
44 46 except requests.exceptions.RequestException as e:
45 47 return cls.models
48 if cls.live == 0 and models:
49 cls.live += 1
46 50 cls.local_models = [model["name"] for model in models]
47 51 cls.models = cls.models + cls.local_models
48 52 cls.default_model = next(iter(cls.models), None)
Modified g4f/Provider/needs_auth/Cohere.py +2 -0
@@ -33,6 +33,8 @@ class Cohere(AsyncGeneratorProvider, ProviderModelMixin):
33 33 api_key = AuthManager.load_api_key(cls)
34 34 url = "https://api.cohere.com/v1/models?page_size=500&endpoint=chat"
35 35 models = requests.get(url, headers={"Authorization": f"Bearer {api_key}" }).json().get("models", [])
36 if models:
37 cls.live += 1
36 38 cls.models = [model.get("name") for model in models if "chat" in model.get("endpoints")]
37 39 cls.vision_models = {model.get("name") for model in models if model.get("supports_vision")}
38 40 return cls.models
Modified g4f/Provider/qwen/QwenCode.py +8 -1
@@ -15,9 +15,16 @@ class QwenCode(OpenaiTemplate):
15 15 needs_auth = True
16 16 active_by_default = True
17 17 default_model = "qwen3-coder-plus"
18 models = [default_model]
19 18 client = QwenContentGenerator(QwenOAuth2Client())
20 19
20 @classmethod
21 def get_models(cls, **kwargs):
22 if not cls.models:
23 cls.models = [cls.default_model]
24 if cls.live == 0 and cls.client.shared_manager.isTokenValid(cls.client.shared_manager.getCurrentCredentials()):
25 cls.live += 1
26 return cls.models
27
21 28 @classmethod
22 29 async def create_async_generator(
23 30 cls,