summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-20 15:41:49 +0200
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-20 15:41:49 +0200
commit83484c0a5658b023bcef930aee5099a4fc059cb4 (patch)
tree36b4467e36c9363e997c0706f0bdcdcae26ed0aa /examples
parentAdd MetaAI Provider and some small improvments (diff)
downloadgpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.tar
gpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.tar.gz
gpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.tar.bz2
gpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.tar.lz
gpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.tar.xz
gpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.tar.zst
gpt4free-83484c0a5658b023bcef930aee5099a4fc059cb4.zip
Diffstat (limited to 'examples')
-rw-r--r--examples/ecosia.py18
-rw-r--r--examples/openaichat.py23
2 files changed, 0 insertions, 41 deletions
diff --git a/examples/ecosia.py b/examples/ecosia.py
deleted file mode 100644
index 5a2ae520..00000000
--- a/examples/ecosia.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import asyncio
-import g4f
-from g4f.client import AsyncClient
-
-async def main():
- client = AsyncClient(
- provider=g4f.Provider.Ecosia,
- )
- async for chunk in client.chat.completions.create(
- [{"role": "user", "content": "happy dogs on work. write some lines"}],
- g4f.models.default,
- stream=True,
- green=True,
- ):
- print(chunk.choices[0].delta.content or "", end="")
- print(f"\nwith {chunk.model}")
-
-asyncio.run(main()) \ No newline at end of file
diff --git a/examples/openaichat.py b/examples/openaichat.py
deleted file mode 100644
index 291daa2c..00000000
--- a/examples/openaichat.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from g4f.client import Client
-from g4f.Provider import OpenaiChat, RetryProvider
-
-# compatible countries: https://pastebin.com/UK0gT9cn
-client = Client(
- proxies = {
- 'http': 'http://username:password@host:port', # MUST BE WORKING OPENAI COUNTRY PROXY ex: USA
- 'https': 'http://username:password@host:port' # MUST BE WORKING OPENAI COUNTRY PROXY ex: USA
- },
- provider = RetryProvider([OpenaiChat],
- single_provider_retry=True, max_retries=5)
-)
-
-messages = [
- {'role': 'user', 'content': 'Hello'}
-]
-
-response = client.chat.completions.create(model='gpt-3.5-turbo',
- messages=messages,
- stream=True)
-
-for message in response:
- print(message.choices[0].delta.content or "") \ No newline at end of file