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

XFEstudio/gpt4free

Refactor ProviderUtils.get_by_label to use class method and improve provider retrieval logic

5c07ed0c
hlohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +4 -3
Modified g4f/Provider/__init__.py +4 -3
@@ -76,12 +76,13 @@ __map__: dict[str, ProviderType] = {
76 76 class ProviderUtils:
77 77 convert: dict[str, ProviderType] = __map__
78 78
79 def get_by_label(self, label: str) -> ProviderType:
79 @classmethod
80 def get_by_label(cls, label: str) -> ProviderType:
80 81 if not label:
81 82 raise ValueError("Label must be provided")
82 provider = self.convert.get(label)
83 provider = cls.convert.get(label)
83 84 if provider is None:
84 for provider_cls in self.__providers__:
85 for provider_cls in cls.convert.values():
85 86 if provider_cls.working and provider_cls.__name__.lower().startswith(label.lower()):
86 87 provider = provider_cls
87 88 break