summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/base_provider.py
diff options
context:
space:
mode:
authorMIDORIBIN <aquarion123@gmail.com>2023-07-28 12:07:17 +0200
committerMIDORIBIN <aquarion123@gmail.com>2023-08-14 04:46:32 +0200
commitf6ef3cb2237d8c336e915ef77ddbe6f37934c4fd (patch)
treec8bc44917ea03909cf586140f984ff0814bc30ea /g4f/Provider/base_provider.py
parent~ | small fixes & new pypi version | v-0.0.1.9 (diff)
downloadgpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.gz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.bz2
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.lz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.xz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.zst
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.zip
Diffstat (limited to 'g4f/Provider/base_provider.py')
-rw-r--r--g4f/Provider/base_provider.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/g4f/Provider/base_provider.py b/g4f/Provider/base_provider.py
new file mode 100644
index 00000000..92636fda
--- /dev/null
+++ b/g4f/Provider/base_provider.py
@@ -0,0 +1,33 @@
+from abc import ABC, abstractmethod
+
+from ..typing import Any, CreateResult
+
+
+class BaseProvider(ABC):
+ url: str
+ working = False
+ needs_auth = False
+ supports_stream = False
+ supports_gpt_35_turbo = False
+ supports_gpt_4 = False
+
+ @staticmethod
+ @abstractmethod
+ def create_completion(
+ model: str,
+ messages: list[dict[str, str]],
+ stream: bool,
+ **kwargs: Any,
+ ) -> CreateResult:
+ raise NotImplementedError()
+
+ @classmethod
+ @property
+ def params(cls):
+ params = [
+ ("model", "str"),
+ ("messages", "list[dict[str, str]]"),
+ ("stream", "bool"),
+ ]
+ param = ", ".join([": ".join(p) for p in params])
+ return f"g4f.provider.{cls.__name__} supports: ({param})"