summaryrefslogblamecommitdiffstats
path: root/examples/ecosia.py
blob: 5a2ae520d0a7e6d6b5e5a0685700b6a22caa32d2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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())