Add GeminiPro API provider

Set min version for undetected-chromedriver
Add api_key to the new client
This commit is contained in:
Heiner Lohaus 2024-02-23 11:33:38 +01:00
parent 51b4aaae05
commit 51264fe20c
11 changed files with 223 additions and 68 deletions

View file

@ -37,12 +37,16 @@ client = Client(
)
```
You also have the option to define a proxy in the client for all outgoing requests:
## Configuration
You can set an "api_key" for your provider in client.
And you also have the option to define a proxy for all outgoing requests:
```python
from g4f.client import Client
client = Client(
api_key="...",
proxies="http://user:pass@host",
...
)
@ -74,7 +78,7 @@ stream = client.chat.completions.create(
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
print(chunk.choices[0].delta.content or "", end="")
```
**Image Generation:**
@ -109,7 +113,28 @@ image_url = response.data[0].url
Original / Variant:
[![Original Image](/docs/cat.jpeg)](/docs/client.md)
[![Variant Image](/docs/cat.webp)](/docs/client.md)
[![Original Image](/docs/cat.jpeg)](/docs/client.md) [![Variant Image](/docs/cat.webp)](/docs/client.md)
#### Advanced example using GeminiProVision
```python
from g4f.client import Client
from g4f.Provider.GeminiPro import GeminiPro
client = Client(
api_key="...",
provider=GeminiPro
)
response = client.chat.completions.create(
model="gemini-pro-vision",
messages=[{"role": "user", "content": "What are on this image?"}],
image=open("docs/cat.jpeg", "rb")
)
print(response.choices[0].message.content)
```
**Question:** What are on this image?
```
A cat is sitting on a window sill looking at a bird outside the window.
```
[Return to Home](/)