summaryrefslogtreecommitdiffstats
path: root/g4f/__init__.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2023-12-10 21:46:11 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2023-12-10 21:46:11 +0100
commitbf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3 (patch)
treecc9dcbdc5bc3b81050ff74a47d00e13c9c63570c /g4f/__init__.py
parentFix llama2 provider, Update TOC in readme (#1325) (diff)
downloadgpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.tar
gpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.tar.gz
gpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.tar.bz2
gpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.tar.lz
gpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.tar.xz
gpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.tar.zst
gpt4free-bf41cfc5d1d7ef6e2e8dde6237e54757c22b66b3.zip
Diffstat (limited to '')
-rw-r--r--g4f/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/g4f/__init__.py b/g4f/__init__.py
index 92bce194..c7909bd4 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -96,6 +96,10 @@ class ChatCompletion:
if auth:
kwargs['auth'] = auth
+
+ proxy = os.environ.get("G4F_PROXY")
+ if proxy and "proxy" not in kwargs:
+ kwargs['proxy'] = proxy
result = provider.create_completion(model.name, messages, stream, **kwargs)
return result if stream else ''.join(result)
@@ -112,7 +116,7 @@ class ChatCompletion:
if stream:
if isinstance(provider, type) and issubclass(provider, AsyncGeneratorProvider):
return await provider.create_async_generator(model.name, messages, **kwargs)
- raise ValueError(f'{provider.__name__} does not support "stream" argument')
+ raise ValueError(f'{provider.__name__} does not support "stream" argument in "create_async"')
return await provider.create_async(model.name, messages, **kwargs)