summaryrefslogtreecommitdiffstats
path: root/tool/provider_init.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 /tool/provider_init.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 '')
-rw-r--r--tool/provider_init.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tool/provider_init.py b/tool/provider_init.py
new file mode 100644
index 00000000..22f21d4d
--- /dev/null
+++ b/tool/provider_init.py
@@ -0,0 +1,33 @@
+from pathlib import Path
+
+
+def main():
+ content = create_content()
+ with open("g4f/provider/__init__.py", "w", encoding="utf-8") as f:
+ f.write(content)
+
+
+def create_content():
+ path = Path()
+ paths = path.glob("g4f/provider/*.py")
+ paths = [p for p in paths if p.name not in ["__init__.py", "base_provider.py"]]
+ classnames = [p.stem for p in paths]
+
+ import_lines = [f"from .{name} import {name}" for name in classnames]
+ import_content = "\n".join(import_lines)
+
+ classnames.insert(0, "BaseProvider")
+ all_content = [f' "{name}"' for name in classnames]
+ all_content = ",\n".join(all_content)
+ all_content = f"__all__ = [\n{all_content},\n]"
+
+ return f"""from .base_provider import BaseProvider
+{import_content}
+
+
+{all_content}
+"""
+
+
+if __name__ == "__main__":
+ main()