diff options
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/__init__.py | 28 | ||||
-rw-r--r-- | g4f/gui/run.py | 4 | ||||
-rw-r--r-- | g4f/interference/run.py | 4 | ||||
-rw-r--r-- | g4f/typing.py | 2 |
4 files changed, 24 insertions, 14 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 diff --git a/g4f/gui/run.py b/g4f/gui/run.py new file mode 100644 index 00000000..da672d59 --- /dev/null +++ b/g4f/gui/run.py @@ -0,0 +1,4 @@ +from g4f.gui import run_gui + +if __name__ == '__main__': + run_gui()
\ No newline at end of file diff --git a/g4f/interference/run.py b/g4f/interference/run.py new file mode 100644 index 00000000..e527ce11 --- /dev/null +++ b/g4f/interference/run.py @@ -0,0 +1,4 @@ +from g4f.interference import run_interference + +if __name__ == '__main__': + run_interference()
\ No newline at end of file diff --git a/g4f/typing.py b/g4f/typing.py index 840e4624..cfddf4a8 100644 --- a/g4f/typing.py +++ b/g4f/typing.py @@ -8,7 +8,7 @@ else: SHA256 = NewType('sha_256_hash', str) CreateResult = Generator[str, None, None] -AsyncResult = AsyncGenerator[str] +AsyncResult = AsyncGenerator[str, None] Messages = List[Dict[str, str]] __all__ = [ |