summaryrefslogtreecommitdiffstats
path: root/g4f/__init__.py
diff options
context:
space:
mode:
authorabc <98614666+xtekky@users.noreply.github.com>2023-10-08 14:31:46 +0200
committerabc <98614666+xtekky@users.noreply.github.com>2023-10-08 14:31:46 +0200
commit64fe0ee487c506febdc5126e7a8c9f2e30165101 (patch)
treed99705e1488883eeae70642a8e91071d3b0cdbf0 /g4f/__init__.py
parent~ | Merge pull request #1012 from hlohaus/hey (diff)
downloadgpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.tar
gpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.tar.gz
gpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.tar.bz2
gpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.tar.lz
gpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.tar.xz
gpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.tar.zst
gpt4free-64fe0ee487c506febdc5126e7a8c9f2e30165101.zip
Diffstat (limited to '')
-rw-r--r--g4f/__init__.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/g4f/__init__.py b/g4f/__init__.py
index bd4bfde0..4b1e4b80 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -5,7 +5,8 @@ from .Provider import BaseProvider
from .typing import CreateResult, Union
from .debug import logging
-version = '0.1.5.5'
+version = '0.1.5.6'
+version_check = True
def check_pypi_version() -> None:
try:
@@ -18,9 +19,10 @@ def check_pypi_version() -> None:
except Exception as e:
print(f'Failed to check g4f pypi version: {e}')
-check_pypi_version()
-
-def get_model_and_provider(model: Union[Model, str], provider: Union[type[BaseProvider], None], stream: bool) -> tuple[Model, type[BaseProvider]]:
+def get_model_and_provider(model : Union[Model, str],
+ provider : Union[type[BaseProvider], None],
+ stream : bool) -> tuple[Model, type[BaseProvider]]:
+
if isinstance(model, str):
if model in ModelUtils.convert:
model = ModelUtils.convert[model]
@@ -46,14 +48,11 @@ def get_model_and_provider(model: Union[Model, str], provider: Union[type[BasePr
class ChatCompletion:
@staticmethod
- def create(
- model: Union[Model, str],
- messages: list[dict[str, str]],
- provider: Union[type[BaseProvider], None] = None,
- stream: bool = False,
- auth: Union[str, None] = None,
- **kwargs
- ) -> Union[CreateResult, str]:
+ def create(model: Union[Model, str],
+ messages : list[dict[str, str]],
+ provider : Union[type[BaseProvider], None] = None,
+ stream : bool = False,
+ auth : Union[str, None] = None, **kwargs) -> Union[CreateResult, str]:
model, provider = get_model_and_provider(model, provider, stream)
@@ -104,4 +103,7 @@ class Completion:
result = provider.create_completion(model.name, [{"role": "user", "content": prompt}], stream, **kwargs)
- return result if stream else ''.join(result) \ No newline at end of file
+ return result if stream else ''.join(result)
+
+if version_check:
+ check_pypi_version() \ No newline at end of file