summaryrefslogtreecommitdiffstats
path: root/examples/ecosia.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-18 21:13:26 +0200
committerGitHub <noreply@github.com>2024-04-18 21:13:26 +0200
commit718ea7c187b0852aacc18bf890fcc105dfff2665 (patch)
tree84f59d4ea5a679382df3f71ff3de027aad2a8fd4 /examples/ecosia.py
parentMerge pull request #1848 from hlohaus/nem (diff)
parentAdd Ecosia Provider, Add OpenaiAccount alias (diff)
downloadgpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.tar
gpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.tar.gz
gpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.tar.bz2
gpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.tar.lz
gpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.tar.xz
gpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.tar.zst
gpt4free-718ea7c187b0852aacc18bf890fcc105dfff2665.zip
Diffstat (limited to 'examples/ecosia.py')
-rw-r--r--examples/ecosia.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/ecosia.py b/examples/ecosia.py
new file mode 100644
index 00000000..5a2ae520
--- /dev/null
+++ b/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