Skip to content

Commit 5c07ed0

Browse files
committed
Refactor ProviderUtils.get_by_label to use class method and improve provider retrieval logic
1 parent 671c0fc commit 5c07ed0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

g4f/Provider/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@
7676
class ProviderUtils:
7777
convert: dict[str, ProviderType] = __map__
7878

79-
def get_by_label(self, label: str) -> ProviderType:
79+
@classmethod
80+
def get_by_label(cls, label: str) -> ProviderType:
8081
if not label:
8182
raise ValueError("Label must be provided")
82-
provider = self.convert.get(label)
83+
provider = cls.convert.get(label)
8384
if provider is None:
84-
for provider_cls in self.__providers__:
85+
for provider_cls in cls.convert.values():
8586
if provider_cls.working and provider_cls.__name__.lower().startswith(label.lower()):
8687
provider = provider_cls
8788
break

0 commit comments

Comments
 (0)