mirror of https://github.com/xtekky/gpt4free.git
~ | 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:
parent
d804b20694
commit
64fe0ee487
|
@ -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.
|
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
|
```sh
|
||||||
pip install -U g4f
|
pip install -U g4f
|
||||||
```
|
```
|
||||||
|
|
|
@ -5,7 +5,8 @@ from .Provider import BaseProvider
|
||||||
from .typing import CreateResult, Union
|
from .typing import CreateResult, Union
|
||||||
from .debug import logging
|
from .debug import logging
|
||||||
|
|
||||||
version = '0.1.5.5'
|
version = '0.1.5.6'
|
||||||
|
version_check = True
|
||||||
|
|
||||||
def check_pypi_version() -> None:
|
def check_pypi_version() -> None:
|
||||||
try:
|
try:
|
||||||
|
@ -18,9 +19,10 @@ def check_pypi_version() -> None:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Failed to check g4f pypi version: {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 isinstance(model, str):
|
||||||
if model in ModelUtils.convert:
|
if model in ModelUtils.convert:
|
||||||
model = ModelUtils.convert[model]
|
model = ModelUtils.convert[model]
|
||||||
|
@ -46,14 +48,11 @@ def get_model_and_provider(model: Union[Model, str], provider: Union[type[BasePr
|
||||||
|
|
||||||
class ChatCompletion:
|
class ChatCompletion:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(
|
def create(model: Union[Model, str],
|
||||||
model: Union[Model, str],
|
|
||||||
messages : list[dict[str, str]],
|
messages : list[dict[str, str]],
|
||||||
provider : Union[type[BaseProvider], None] = None,
|
provider : Union[type[BaseProvider], None] = None,
|
||||||
stream : bool = False,
|
stream : bool = False,
|
||||||
auth: Union[str, None] = None,
|
auth : Union[str, None] = None, **kwargs) -> Union[CreateResult, str]:
|
||||||
**kwargs
|
|
||||||
) -> Union[CreateResult, str]:
|
|
||||||
|
|
||||||
model, provider = get_model_and_provider(model, provider, stream)
|
model, provider = get_model_and_provider(model, provider, stream)
|
||||||
|
|
||||||
|
@ -105,3 +104,6 @@ class Completion:
|
||||||
result = provider.create_completion(model.name, [{"role": "user", "content": prompt}], stream, **kwargs)
|
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()
|
|
@ -0,0 +1,4 @@
|
||||||
|
from g4f.gui import run_gui
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run_gui()
|
|
@ -0,0 +1,4 @@
|
||||||
|
from g4f.interference import run_interference
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run_interference()
|
|
@ -8,7 +8,7 @@ else:
|
||||||
|
|
||||||
SHA256 = NewType('sha_256_hash', str)
|
SHA256 = NewType('sha_256_hash', str)
|
||||||
CreateResult = Generator[str, None, None]
|
CreateResult = Generator[str, None, None]
|
||||||
AsyncResult = AsyncGenerator[str]
|
AsyncResult = AsyncGenerator[str, None]
|
||||||
Messages = List[Dict[str, str]]
|
Messages = List[Dict[str, str]]
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -14,7 +14,7 @@ with open("requirements.txt") as f:
|
||||||
with open("etc/interference/requirements.txt") as f:
|
with open("etc/interference/requirements.txt") as f:
|
||||||
api_required = f.read().splitlines()
|
api_required = f.read().splitlines()
|
||||||
|
|
||||||
VERSION = '0.1.5.5'
|
VERSION = '0.1.5.6'
|
||||||
DESCRIPTION = (
|
DESCRIPTION = (
|
||||||
"The official gpt4free repository | various collection of powerful language models"
|
"The official gpt4free repository | various collection of powerful language models"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue