diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 17:21:10 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 17:21:10 +0100 |
commit | 7953560303ad82f13f3d4c910db1193da21b11d7 (patch) | |
tree | e88b25bcc756e02741ea1875fcf62ff9ba76b975 /docs/client.md | |
parent | Fix isssue with stop in client (diff) | |
download | gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.gz gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.bz2 gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.lz gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.xz gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.tar.zst gpt4free-7953560303ad82f13f3d4c910db1193da21b11d7.zip |
Diffstat (limited to '')
-rw-r--r-- | docs/client.md | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/docs/client.md b/docs/client.md index 7d3cad11..fe02dc92 100644 --- a/docs/client.md +++ b/docs/client.md @@ -1,4 +1,4 @@ -### G4F - Client API (Beta Version) +### G4F - Client API #### Introduction @@ -39,7 +39,7 @@ client = Client( ## Configuration -You can set an "api_key" for your provider in client. +You can set an "api_key" for your provider in the client. And you also have the option to define a proxy for all outgoing requests: ```python @@ -108,13 +108,35 @@ response = client.images.create_variation( image_url = response.data[0].url ``` - -#### Visual Examples - Original / Variant: [![Original Image](/docs/cat.jpeg)](/docs/client.md) [![Variant Image](/docs/cat.webp)](/docs/client.md) +#### Use a list of providers with RetryProvider + +```python +from g4f.client import Client +from g4f.Provider import RetryProvider, Phind, FreeChatgpt, Liaobots + +import g4f.debug +g4f.debug.logging = True + +client = Client( + provider=RetryProvider([Phind, FreeChatgpt, Liaobots], shuffle=False) +) +response = client.chat.completions.create( + model="", + messages=[{"role": "user", "content": "Hello"}], +) +print(response.choices[0].message.content) +``` + +``` +Using RetryProvider provider +Using Phind provider +How can I assist you today? +``` + #### Advanced example using GeminiProVision ```python @@ -128,13 +150,16 @@ client = Client( response = client.chat.completions.create( model="gemini-pro-vision", messages=[{"role": "user", "content": "What are on this image?"}], - image=open("docs/cat.jpeg", "rb") + image=open("docs/waterfall.jpeg", "rb") ) print(response.choices[0].message.content) ``` -**Question:** What are on this image? +![Waterfall](/docs/waterfall.jpeg) +``` +User: What are on this image? +``` ``` - A cat is sitting on a window sill looking at a bird outside the window. +Bot: There is a waterfall in the middle of a jungle. There is a rainbow over... ``` [Return to Home](/)
\ No newline at end of file |