Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
doc: update send request methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark authored Mar 20, 2024
1 parent ef7d3aa commit 638eb80
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ pip install -q -U python-gemini-api
```python
from gemini import Gemini
GeminiClient = Gemini(auto_cookies=True)
# GeminiClient = Gemini(auto_cookies=True, target_cookies = ["__Secure-1PSID", "__Secure-1PSIDTS"]) # Can select cookies.

# Testing needed as cookies vary by region.
# GeminiClient = Gemini(auto_cookies=True, target_cookies=["__Secure-1PSID", "__Secure-1PSIDTS"])

response = GeminiClient.generate_content("Hello, Gemini. What's the weather like in Seoul today?")
print(response.payload)
```
Expand Down Expand Up @@ -106,33 +109,45 @@ pip install -q -U python-gemini-api

*Simple usage*

Setting Gemini Response Language (Optional): Check supported languages [here](https://developers.google.com/hotels/hotel-prices/dev-guide/country-codes). Default is English.
Setting Gemini response language (Optional): Check supported languages [here](https://developers.google.com/hotels/hotel-prices/dev-guide/country-codes). Default is English.

```python
import os
os.environ["GEMINI_LANGUAGE"] = "KR"
```

Generate content
Send request: returns original payload.
```python
from gemini import Gemini

cookies = {} # Cookies may vary by account or region. Consider sending the entire cookie file.
GeminiClient = Gemini(cookies=cookies) # You can use various args

response_text, response_status = GeminiClient.send_request("Hello, Gemini. What's the weather like in Seoul today?")
print(response_text)
```


Generate content: returns parsed response.
```python
from gemini import Gemini

cookies = {} # Cookies may vary by account or region. Consider sending the entire cookie file.
GeminiClient = Gemini(cookies=cookies) # You can use various args

response = GeminiClient.generate_content("Hello, Gemini. What's the weather like in Seoul today?")
response.response_dict # renamed to payload after v2.3.0
response.payload
```

Generate content from image
Generate content from image: you can use image as input.
```python
from gemini import Gemini

cookies = {} # Cookies may vary by account or region. Consider sending the entire cookie file.

GeminiClient = Gemini(cookies=cookies) # You can use various args
response = GeminiClient.generate_content("What does the text in this image say?", image='folder/image.jpg')
response.response_dict # renamed to payload after v2.3.0
response.payload
```

> [!NOTE]
Expand All @@ -159,7 +174,7 @@ cookies = {
}

GeminiClient = Gemini(cookies=cookies)
# GeminiClient = Gemini(cookie_fp="folder/cookie_file.json") # Or use cookie file path
# GeminiClient = Gemini(cookie_fp="folder/cookie_file.json") # (*.json, *.txt) are supported.
# GeminiClient = Gemini(auto_cookies=True) # Or use auto_cookies paprameter
```

Expand All @@ -180,7 +195,7 @@ https://github.com/dsdanielpark/Gemini-API/blob/fdf064c57bc1fb47fbbb4b93067618a2
```python
prompt = "Hello, Gemini. What's the weather like in Seoul today?"
response = GeminiClient.generate_content(prompt)
print(response.response_dict) # renamed to payload after v2.3.0
print(response.payload)
```
> [!IMPORTANT]
> Once connected and generating valid content, **Be sure to CLOSE the Gemini website or CLOSE your browser** for cookie stability.
Expand Down

0 comments on commit 638eb80

Please sign in to comment.