From fd97cceab0727e0e97e15c45c5b7ba979e143562 Mon Sep 17 00:00:00 2001 From: hlohaus <983577+hlohaus@users.noreply.github.com> Date: Fri, 24 Jan 2025 04:56:26 +0100 Subject: Restore AsyncClient streaming return type Improve error handling in DDG use OpenaiAPI provider in DeepInfraChat Support api_base and response_type parameters in API --- docs/async_client.md | 9 ++++----- docs/client.md | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/async_client.md b/docs/async_client.md index b00df7ef..09a6f009 100644 --- a/docs/async_client.md +++ b/docs/async_client.md @@ -149,8 +149,8 @@ from g4f.client import AsyncClient async def main(): client = AsyncClient() - - stream = await client.chat.completions.create( + + stream = client.chat.completions.stream( model="gpt-4", messages=[ { @@ -158,10 +158,9 @@ async def main(): "content": "Say this is a test" } ], - stream=True, web_search = False ) - + async for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="") @@ -366,7 +365,7 @@ async def main(): "query": "Latest advancements in AI", "max_results": 5, "max_words": 2500, - "backend": "api", + "backend": "auto", "add_text": True, "timeout": 5 }, diff --git a/docs/client.md b/docs/client.md index 274e997c..e47e9207 100644 --- a/docs/client.md +++ b/docs/client.md @@ -386,7 +386,7 @@ tool_calls = [ "query": "Latest advancements in AI", "max_results": 5, "max_words": 2500, - "backend": "api", + "backend": "auto", "add_text": True, "timeout": 5 }, -- cgit v1.2.3