aient 1.2.45__py3-none-any.whl → 1.2.47__py3-none-any.whl
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.
- aient/architext/architext/core.py +9 -1
- aient/architext/test/test.py +26 -0
- aient/core/request.py +3 -0
- aient/core/utils.py +1 -1
- {aient-1.2.45.dist-info → aient-1.2.47.dist-info}/METADATA +1 -1
- {aient-1.2.45.dist-info → aient-1.2.47.dist-info}/RECORD +9 -9
- {aient-1.2.45.dist-info → aient-1.2.47.dist-info}/WHEEL +0 -0
- {aient-1.2.45.dist-info → aient-1.2.47.dist-info}/licenses/LICENSE +0 -0
- {aient-1.2.45.dist-info → aient-1.2.47.dist-info}/top_level.txt +0 -0
@@ -423,8 +423,16 @@ class Message(ABC):
|
|
423
423
|
processed_items.append(Images(url=image_url))
|
424
424
|
else:
|
425
425
|
raise ValueError(f"Unsupported item type in list: {item_type}")
|
426
|
+
elif isinstance(item, dict):
|
427
|
+
item_type = item.get('type')
|
428
|
+
if item_type == 'image_url':
|
429
|
+
image_url = item.get('image_url', {}).get('url')
|
430
|
+
if image_url:
|
431
|
+
processed_items.append(Images(url=image_url))
|
432
|
+
else:
|
433
|
+
raise ValueError(f"Unsupported dict item type: {item_type}")
|
426
434
|
else:
|
427
|
-
raise TypeError(f"Unsupported item type: {type(item)}. Must be str, ContextProvider, or
|
435
|
+
raise TypeError(f"Unsupported item type: {type(item)}. Must be str, ContextProvider, list, or dict.")
|
428
436
|
self._items: List[ContextProvider] = processed_items
|
429
437
|
self._parent_messages: Optional['Messages'] = None
|
430
438
|
|
aient/architext/test/test.py
CHANGED
@@ -1884,6 +1884,32 @@ Files: {Files(visible=True, name="files")}
|
|
1884
1884
|
if os.path.exists(non_existent_file):
|
1885
1885
|
os.remove(non_existent_file)
|
1886
1886
|
|
1887
|
+
async def test_auto_convert_image_dict_to_image_provider(self):
|
1888
|
+
"""测试 UserMessage 是否能自动转换 image_url 字典为 Images provider"""
|
1889
|
+
base64_image_data = "/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAAAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9/KKKKAP/2Q=="
|
1890
|
+
image_dict = {
|
1891
|
+
'type': 'image_url',
|
1892
|
+
'image_url': {
|
1893
|
+
'url': f'data:image/jpeg;base64,{base64_image_data}'
|
1894
|
+
}
|
1895
|
+
}
|
1896
|
+
|
1897
|
+
# This is the functionality we are testing.
|
1898
|
+
# The UserMessage should be able to take this dictionary directly.
|
1899
|
+
message = UserMessage(image_dict)
|
1900
|
+
|
1901
|
+
# 1. Verify that the message contains exactly one provider.
|
1902
|
+
self.assertEqual(len(message.provider()), 1)
|
1903
|
+
|
1904
|
+
# 2. Verify that the provider is an instance of the Images class.
|
1905
|
+
image_provider = message.provider()[0]
|
1906
|
+
self.assertIsInstance(image_provider, Images)
|
1907
|
+
|
1908
|
+
# 3. Verify that the content of the Images provider is correct.
|
1909
|
+
rendered = await message.render_latest()
|
1910
|
+
self.assertEqual(rendered['content'][0]['image_url']['url'], image_dict['image_url']['url'])
|
1911
|
+
|
1912
|
+
|
1887
1913
|
# ==============================================================================
|
1888
1914
|
# 6. 演示
|
1889
1915
|
# ==============================================================================
|
aient/core/request.py
CHANGED
@@ -1116,6 +1116,9 @@ async def get_gpt_payload(request, engine, provider, api_key=None):
|
|
1116
1116
|
if "temperature" in payload:
|
1117
1117
|
payload.pop("temperature")
|
1118
1118
|
|
1119
|
+
if "v1/responses" in url:
|
1120
|
+
payload.pop("stream_options", None)
|
1121
|
+
|
1119
1122
|
# 代码生成/数学解题 0.0
|
1120
1123
|
# 数据抽取/分析 1.0
|
1121
1124
|
# 通用对话 1.3
|
aient/core/utils.py
CHANGED
@@ -52,7 +52,7 @@ class BaseAPI:
|
|
52
52
|
self.v1_models: str = urlunparse(parsed_url[:2] + (before_v1 + "models",) + ("",) * 3)
|
53
53
|
|
54
54
|
if "v1/responses" in parsed_url.path:
|
55
|
-
self.chat_url: str =
|
55
|
+
self.chat_url: str = api_url
|
56
56
|
else:
|
57
57
|
self.chat_url: str = urlunparse(parsed_url[:2] + (before_v1 + "chat/completions",) + ("",) * 3)
|
58
58
|
self.image_url: str = urlunparse(parsed_url[:2] + (before_v1 + "images/generations",) + ("",) * 3)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
aient/__init__.py,sha256=SRfF7oDVlOOAi6nGKiJIUK6B_arqYLO9iSMp-2IZZps,21
|
2
2
|
aient/architext/architext/__init__.py,sha256=79Ih1151rfcqZdr7F8HSZSTs_iT2SKd1xCkehMsXeXs,19
|
3
|
-
aient/architext/architext/core.py,sha256=
|
3
|
+
aient/architext/architext/core.py,sha256=E5QTM0NNoHPxRawH_Lmb01azAAlmLlm0bPy5c78zG38,37972
|
4
4
|
aient/architext/test/openai_client.py,sha256=Dqtbmubv6vwF8uBqcayG0kbsiO65of7sgU2-DRBi-UM,4590
|
5
|
-
aient/architext/test/test.py,sha256=
|
5
|
+
aient/architext/test/test.py,sha256=c6wHwo8DQL5yeEQ3T1lqMleHJ9M5Sifnk4Qqk64Vv7w,90970
|
6
6
|
aient/architext/test/test_save_load.py,sha256=o8DqH6gDYZkFkQy-a7blqLtJTRj5e4a-Lil48pJ0V3g,3260
|
7
7
|
aient/core/__init__.py,sha256=NxjebTlku35S4Dzr16rdSqSTWUvvwEeACe8KvHJnjPg,34
|
8
8
|
aient/core/log_config.py,sha256=kz2_yJv1p-o3lUQOwA3qh-LSc3wMHv13iCQclw44W9c,274
|
9
9
|
aient/core/models.py,sha256=KMlCRLjtq1wQHZTJGqnbWhPS2cHq6eLdnk7peKDrzR8,7490
|
10
|
-
aient/core/request.py,sha256=
|
10
|
+
aient/core/request.py,sha256=JwTlgdFJjf2mi9UbGDAgI2dRj49NnWXnnww7S6VsPIM,77919
|
11
11
|
aient/core/response.py,sha256=VYpXfF6RO3Y-fTZMGV2p-bcrd73BPAKlz33gQkOcqjE,38462
|
12
|
-
aient/core/utils.py,sha256=
|
12
|
+
aient/core/utils.py,sha256=jlEjtsCnnUxp-z9NLCiDbLBxEd9AE0zEWxnpjq7_5ao,31700
|
13
13
|
aient/core/test/test_base_api.py,sha256=pWnycRJbuPSXKKU9AQjWrMAX1wiLC_014Qc9hh5C2Pw,524
|
14
14
|
aient/core/test/test_geminimask.py,sha256=HFX8jDbNg_FjjgPNxfYaR-0-roUrOO-ND-FVsuxSoiw,13254
|
15
15
|
aient/core/test/test_image.py,sha256=_T4peNGdXKBHHxyQNx12u-NTyFE8TlYI6NvvagsG2LE,319
|
@@ -33,8 +33,8 @@ aient/plugins/websearch.py,sha256=aPsBjUQ3zQ4gzNrbVq7BMh28ENj9h_fSAeJFF2h9TNk,15
|
|
33
33
|
aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
34
|
aient/utils/prompt.py,sha256=ZvGAt_ImJ_CGbDnWgpsWskfSV5fCkpFKRpNQjYL7M7s,11100
|
35
35
|
aient/utils/scripts.py,sha256=D_-BCLHV_PS9r6SLXsdEAyey4bVWte-jMMJJKSx0Pcg,42530
|
36
|
-
aient-1.2.
|
37
|
-
aient-1.2.
|
38
|
-
aient-1.2.
|
39
|
-
aient-1.2.
|
40
|
-
aient-1.2.
|
36
|
+
aient-1.2.47.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
|
37
|
+
aient-1.2.47.dist-info/METADATA,sha256=Rpzt0zxL881mvWgRAmy5kIFi6Pfw_zek5f55sniInWE,4842
|
38
|
+
aient-1.2.47.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
39
|
+
aient-1.2.47.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
|
40
|
+
aient-1.2.47.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|