From 7e543f4747914f280454f09b070ead500fb72277 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Thu, 18 Apr 2024 20:18:51 +0200 Subject: Add Ecosia Provider, Add OpenaiAccount alias Use AsyncClient in API, add web_search parameter in API Improve error messages in Openai --- examples/ecosia.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/ecosia.py (limited to 'examples') 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 -- cgit v1.2.3