diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 17:27:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 17:27:19 +0100 |
commit | 0687d3c0af7179848ce0b91b8a4f0af2a432edaa (patch) | |
tree | e88b25bcc756e02741ea1875fcf62ff9ba76b975 /docs/client.md | |
parent | Fix isssue with stop in client (diff) | |
parent | Improve readme, add smartphone guide (diff) | |
download | gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.tar gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.tar.gz gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.tar.bz2 gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.tar.lz gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.tar.xz gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.tar.zst gpt4free-0687d3c0af7179848ce0b91b8a4f0af2a432edaa.zip |
Diffstat (limited to 'docs/client.md')
-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 |