~ | g4f v-0.1.5.6

gui & interference can now be run with:

python -m g4f.gui.run

and

python -m g4f.interference.run
This commit is contained in:
abc 2023-10-08 13:31:46 +01:00
parent d804b20694
commit 64fe0ee487
6 changed files with 26 additions and 16 deletions

View File

@ -2,7 +2,7 @@
By using this repository or any code related to it, you agree to the [legal notice](./LEGAL_NOTICE.md). The author is not responsible for any copies, forks, reuploads made by other users, or anything else related to gpt4free. This is the author's only account and repository. To prevent impersonation or irresponsible actions, please comply with the GNU GPL license this Repository uses.
- latest pypi version: ([0.1.5.5](https://pypi.org/project/g4f/0.1.5.5)):
- latest pypi version: ([0.1.5.6](https://pypi.org/project/g4f/0.1.5.6)):
```sh
pip install -U g4f
```

View File

@ -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)
return result if stream else ''.join(result)
if version_check:
check_pypi_version()

4
g4f/gui/run.py Normal file
View File

@ -0,0 +1,4 @@
from g4f.gui import run_gui
if __name__ == '__main__':
run_gui()

4
g4f/interference/run.py Normal file
View File

@ -0,0 +1,4 @@
from g4f.interference import run_interference
if __name__ == '__main__':
run_interference()

View File

@ -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__ = [

View File

@ -14,7 +14,7 @@ with open("requirements.txt") as f:
with open("etc/interference/requirements.txt") as f:
api_required = f.read().splitlines()
VERSION = '0.1.5.5'
VERSION = '0.1.5.6'
DESCRIPTION = (
"The official gpt4free repository | various collection of powerful language models"
)