summaryrefslogtreecommitdiffstats
path: root/etc/examples/ecosia.py
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 /etc/examples/ecosia.py
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 'etc/examples/ecosia.py')
-rw-r--r--etc/examples/ecosia.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/etc/examples/ecosia.py b/etc/examples/ecosia.py
new file mode 100644
index 00000000..5a2ae520
--- /dev/null
+++ b/etc/examples/ecosia.py
@@ -0,0 +1,18 @@
+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