summaryrefslogtreecommitdiffstats
path: root/g4f/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/__init__.py')
-rw-r--r--g4f/__init__.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/g4f/__init__.py b/g4f/__init__.py
index a0b4bac6..e5d3d4bf 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -1,12 +1,15 @@
import sys
from . import Provider
-from g4f.models import Model, ModelUtils
+from g4f import models
+logging = False
class ChatCompletion:
@staticmethod
- def create(model: Model.model or str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs):
+ def create(model: models.Model | str, messages: list, provider: Provider.Provider = None, stream: bool = False, auth: str = False, **kwargs):
kwargs['auth'] = auth
+ if provider and provider.working == False:
+ return f'{provider.__name__} is not working'
if provider and provider.needs_auth and not auth:
print(
@@ -16,7 +19,7 @@ class ChatCompletion:
try:
if isinstance(model, str):
try:
- model = ModelUtils.convert[model]
+ model = models.ModelUtils.convert[model]
except KeyError:
raise Exception(f'The model: {model} does not exist')
@@ -27,7 +30,7 @@ class ChatCompletion:
f"ValueError: {engine.__name__} does not support 'stream' argument", file=sys.stderr)
sys.exit(1)
- print(f'Using {engine.__name__} provider')
+ if logging: print(f'Using {engine.__name__} provider')
return (engine._create_completion(model.name, messages, stream, **kwargs)
if stream else ''.join(engine._create_completion(model.name, messages, stream, **kwargs)))