gemini-webapi 1.12.0__tar.gz → 1.12.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/PKG-INFO +1 -1
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/types/candidate.py +13 -1
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi.egg-info/PKG-INFO +1 -1
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi.egg-info/SOURCES.txt +1 -0
- gemini_webapi-1.12.1/tests/test_html_entity_decode.py +48 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/.github/dependabot.yml +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/.github/workflows/github-release.yml +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/.github/workflows/pypi-publish.yml +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/.gitignore +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/.vscode/launch.json +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/.vscode/settings.json +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/LICENSE +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/README.md +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/assets/banner.png +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/assets/favicon.png +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/assets/logo.svg +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/assets/sample.pdf +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/pyproject.toml +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/setup.cfg +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/__init__.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/client.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/constants.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/exceptions.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/types/__init__.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/types/image.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/types/modeloutput.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/__init__.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/get_access_token.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/load_browser_cookies.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/logger.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/rotate_1psidts.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/upload_file.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi.egg-info/dependency_links.txt +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi.egg-info/requires.txt +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi.egg-info/top_level.txt +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/tests/test_client_features.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/tests/test_rotate_cookies.py +0 -0
- {gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/tests/test_save_image.py +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import html
|
|
2
|
+
from pydantic import BaseModel, field_validator
|
|
2
3
|
|
|
3
4
|
from .image import Image, WebImage, GeneratedImage
|
|
4
5
|
|
|
@@ -33,6 +34,17 @@ class Candidate(BaseModel):
|
|
|
33
34
|
def __repr__(self):
|
|
34
35
|
return f"Candidate(rcid='{self.rcid}', text='{len(self.text) <= 20 and self.text or self.text[:20] + '...'}', images={self.images})"
|
|
35
36
|
|
|
37
|
+
@field_validator("text", "thoughts")
|
|
38
|
+
@classmethod
|
|
39
|
+
def decode_html(cls, value: str) -> str:
|
|
40
|
+
"""
|
|
41
|
+
Auto unescape HTML entities in text/thoughts if any.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
if value:
|
|
45
|
+
value = html.unescape(value)
|
|
46
|
+
return value
|
|
47
|
+
|
|
36
48
|
@property
|
|
37
49
|
def images(self) -> list[Image]:
|
|
38
50
|
return self.web_images + self.generated_images
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from gemini_webapi.types.candidate import Candidate
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestHtmlEntityDecode(unittest.TestCase):
|
|
6
|
+
def test_html_entity_decoding(self):
|
|
7
|
+
# Test HTML entity decoding functionality
|
|
8
|
+
html_encoded_text = (
|
|
9
|
+
"This is a code snippet: <code>print('Hello, World!')</code>"
|
|
10
|
+
)
|
|
11
|
+
expected_decoded_text = (
|
|
12
|
+
"This is a code snippet: <code>print('Hello, World!')</code>"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Create Candidate instance which should automatically decode HTML entities
|
|
16
|
+
candidate = Candidate(
|
|
17
|
+
rcid="test_rcid",
|
|
18
|
+
text=html_encoded_text,
|
|
19
|
+
thoughts="Testing <b>HTML</b> entity decoding",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Verify that text property is correctly decoded
|
|
23
|
+
self.assertEqual(candidate.text, expected_decoded_text)
|
|
24
|
+
|
|
25
|
+
# Verify that thoughts property is correctly decoded
|
|
26
|
+
self.assertEqual(candidate.thoughts, "Testing <b>HTML</b> entity decoding")
|
|
27
|
+
|
|
28
|
+
def test_non_html_text(self):
|
|
29
|
+
# Test plain text without any HTML entities
|
|
30
|
+
plain_text = "This is regular text with no HTML entities"
|
|
31
|
+
|
|
32
|
+
candidate = Candidate(rcid="test_rcid", text=plain_text)
|
|
33
|
+
|
|
34
|
+
# Verify the text remains unchanged
|
|
35
|
+
self.assertEqual(candidate.text, plain_text)
|
|
36
|
+
|
|
37
|
+
def test_complex_html_entities(self):
|
|
38
|
+
# Test more complex combinations of HTML entities
|
|
39
|
+
complex_html = "<div>This has &amp; character\n and "quotes"</div>"
|
|
40
|
+
expected_decoded = '<div>This has & character\n and "quotes"</div>'
|
|
41
|
+
|
|
42
|
+
candidate = Candidate(rcid="test_rcid", text=complex_html)
|
|
43
|
+
|
|
44
|
+
self.assertEqual(candidate.text, expected_decoded)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi/utils/load_browser_cookies.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gemini_webapi-1.12.0 → gemini_webapi-1.12.1}/src/gemini_webapi.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|