langfun 0.1.2.dev202503250804__py3-none-any.whl → 0.1.2.dev202503270804__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.
@@ -19,3 +19,5 @@
19
19
  from langfun.core.data.conversion import anthropic
20
20
  from langfun.core.data.conversion import gemini
21
21
  from langfun.core.data.conversion import openai
22
+
23
+ # Placeholder for Google-internal imports.
@@ -110,7 +110,7 @@ def _as_anthropic_format(
110
110
  chunk_preprocessor: Callable[[str | lf.Modality], Any] | None = None,
111
111
  **kwargs
112
112
  ) -> dict[str, Any]:
113
- """Returns the Anthropic format of the chunk."""
113
+ """Returns an Anthropic format message."""
114
114
  return AnthropicMessageConverter(
115
115
  chunk_preprocessor=chunk_preprocessor, **kwargs
116
116
  ).to_value(self)
@@ -121,8 +121,8 @@ def _from_anthropic_format(
121
121
  cls,
122
122
  anthropic_message: dict[str, Any],
123
123
  **kwargs
124
- ) -> dict[str, Any]:
125
- """Returns the Anthropic format of the chunk."""
124
+ ) -> lf.Message:
125
+ """Creates a Langfun message from the Anthropic format message."""
126
126
  del cls
127
127
  return AnthropicMessageConverter(**kwargs).from_value(anthropic_message)
128
128
 
@@ -147,7 +147,7 @@ def _as_gemini_format(
147
147
  chunk_preprocessor: Callable[[str | lf.Modality], Any] | None = None,
148
148
  **kwargs
149
149
  ) -> dict[str, Any]:
150
- """Returns the Gemini format of the chunk."""
150
+ """Returns a Gemini (REST) format message."""
151
151
  return GeminiMessageConverter(
152
152
  chunk_preprocessor=chunk_preprocessor, **kwargs
153
153
  ).to_value(self)
@@ -158,8 +158,8 @@ def _from_gemini_format(
158
158
  cls,
159
159
  gemini_message: dict[str, Any],
160
160
  **kwargs
161
- ) -> dict[str, Any]:
162
- """Returns the Gemini format of the chunk."""
161
+ ) -> lf.Message:
162
+ """Creates a Langfun message from the Gemini (REST) format message."""
163
163
  del cls
164
164
  return GeminiMessageConverter(**kwargs).from_value(gemini_message)
165
165
 
@@ -110,7 +110,7 @@ def _as_openai_format(
110
110
  chunk_preprocessor: Callable[[str | lf.Modality], Any] | None = None,
111
111
  **kwargs
112
112
  ) -> dict[str, Any]:
113
- """Returns the OpenAI format of the chunk."""
113
+ """Returns an OpenAI format message."""
114
114
  return OpenAIMessageConverter(
115
115
  chunk_preprocessor=chunk_preprocessor, **kwargs
116
116
  ).to_value(self)
@@ -121,8 +121,8 @@ def _from_openai_format(
121
121
  cls,
122
122
  openai_message: dict[str, Any],
123
123
  **kwargs
124
- ) -> dict[str, Any]:
125
- """Returns the OpenAI format of the chunk."""
124
+ ) -> lf.Message:
125
+ """Creates a Langfun message from the OpenAI format message."""
126
126
  del cls
127
127
  return OpenAIMessageConverter(**kwargs).from_value(openai_message)
128
128
 
@@ -512,14 +512,12 @@ class MessageConverterTest(unittest.TestCase):
512
512
  def from_value(self, value: tuple[int, ...]) -> message.Message:
513
513
  return message.UserMessage(','.join(str(x) for x in value))
514
514
 
515
- self.assertEqual(
516
- message.Message.convertible_formats,
517
- ['test_format1', 'test_format2', 'test_format3']
518
- )
519
- self.assertEqual(
520
- message.Message.convertible_types,
521
- [int, tuple]
522
- )
515
+ self.assertIn('test_format1', message.Message.convertible_formats)
516
+ self.assertIn('test_format2', message.Message.convertible_formats)
517
+ self.assertIn('test_format3', message.Message.convertible_formats)
518
+
519
+ self.assertIn(int, message.Message.convertible_types)
520
+ self.assertIn(tuple, message.Message.convertible_types)
523
521
  self.assertEqual(
524
522
  message.Message.from_value(1, format='test_format1'),
525
523
  message.UserMessage('1')
@@ -46,6 +46,7 @@ class Image(mime.Mime):
46
46
 
47
47
  @functools.cached_property
48
48
  def size(self) -> tuple[int, int]:
49
+ """Returns the size (width, height) of the image in pixels."""
49
50
  img = pil_open(io.BytesIO(self.to_bytes()))
50
51
  return img.size
51
52
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202503250804
3
+ Version: 0.1.2.dev202503270804
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -14,7 +14,7 @@ langfun/core/logging.py,sha256=W3mLEMXdo210Q5OX3a1ZTc4nU-xMy73-IfNKnsA-RFo,8051
14
14
  langfun/core/logging_test.py,sha256=N7-YvSXC8zvnr2SNwWHOykn1CFmqvIuTLDgn41Ku9JU,6642
15
15
  langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
16
16
  langfun/core/message.py,sha256=1QOs_jIbehBKumQxVQigOXgN03kcGCBt5K706xHkbqg,32750
17
- langfun/core/message_test.py,sha256=X7YoovahWQpLBYbSBdhIw-_SyGgbZEl1TAAhiQ3JNb4,39776
17
+ langfun/core/message_test.py,sha256=GxgLLvnVINAUc1b4BPCH9bYD67UpG3vVUxAjqt84RmY,39886
18
18
  langfun/core/modality.py,sha256=K8pUGuMpfWcOtVcXC_OqVjro1-RhHF6ddQni61DuYzM,4166
19
19
  langfun/core/modality_test.py,sha256=0WL_yd3B4K-FviWdSpDnOwj0f9TQI0v9t6X0vWvvJbo,2415
20
20
  langfun/core/natural_language.py,sha256=3ynSnaYQnjE60LIPK5fyMgdIjubnPYZwzGq4rWPeloE,1177
@@ -43,12 +43,12 @@ langfun/core/coding/python/parsing_test.py,sha256=PIexYpSEhgNaSd4T6QYWzWHzm3sL4V
43
43
  langfun/core/coding/python/sandboxing.py,sha256=yeEdydMkfHk3Hj3-5ykeROpYyLbRfZ4BwGWJYvFBmSI,4001
44
44
  langfun/core/coding/python/sandboxing_test.py,sha256=H_0_pd-_uS-ci5yYhmDTR6-hyzosAFkExziAHndfdDo,2023
45
45
  langfun/core/data/__init__.py,sha256=qllw9ST1vveZv-1E0VM5hezn1YH-OcqGI-yFqQYnWgI,732
46
- langfun/core/data/conversion/__init__.py,sha256=bSml7RCnr8Zmo0QHtSXGli_jHo58SEi2tuO5HJm74RI,839
47
- langfun/core/data/conversion/anthropic.py,sha256=NzMPvgof27BdvDx9-8s8cpkauUcA_V_BVPdFa0-hsqE,4423
46
+ langfun/core/data/conversion/__init__.py,sha256=ZcGntBruvvZSfESO-Tha1nzHfgWEK7I1u78Jw8gsoVU,883
47
+ langfun/core/data/conversion/anthropic.py,sha256=0xf1sWt6WhmG8EsaeLY4Ee7S3FcDWKPOtn6caCBhtrQ,4431
48
48
  langfun/core/data/conversion/anthropic_test.py,sha256=R43PyveNUCHNCvfu6RFsTk0EIKK8M1Gzng0Kay8TlE8,8534
49
- langfun/core/data/conversion/gemini.py,sha256=_PZ5LIhuxJuwl3UVxkSYvAw1LyR3Lopz4lwRJOITDsU,5502
49
+ langfun/core/data/conversion/gemini.py,sha256=k-BJFQ_xuYRTNH_k0cJlZlhN1VrQHiFjckSxRCyUGNY,5523
50
50
  langfun/core/data/conversion/gemini_test.py,sha256=KIaWdY8CIn0YMaSomxTizvwCrljvt7lbDi3WSEbb1FE,7637
51
- langfun/core/data/conversion/openai.py,sha256=OPnlMOaL43GaHbBFnCoRqzaTybBJiZVKcaHt0JLvJrw,4173
51
+ langfun/core/data/conversion/openai.py,sha256=sSpkDSxMJWJ3I1dNICBCzvLsJv4iiLg8FPYLtubBJUM,4181
52
52
  langfun/core/data/conversion/openai_test.py,sha256=38WV_3ofFZiUF10bTKnZp4VyuDP5-81aR3h3Q0HlBm0,5283
53
53
  langfun/core/eval/__init__.py,sha256=OEXr1ZRuvLuhJJfuQ1ZWQ-SvYzjyrtiAAEogYaB7E6o,1933
54
54
  langfun/core/eval/base.py,sha256=qIJnrO1jX5pzY8yoQTtcTn5lGdD9adz5U6C_jla1BV4,75806
@@ -118,7 +118,7 @@ langfun/core/memories/conversation_history_test.py,sha256=AaW8aNoFjxNusanwJDV0r3
118
118
  langfun/core/modalities/__init__.py,sha256=rh74vS_oL3XzD83ZJrDzwmW-8jnJHJ3s2_Prmp3ndYQ,1116
119
119
  langfun/core/modalities/audio.py,sha256=qCrVCX690SG0ps-ZfOtNWvHn_CmdJsmxF7GySScWUqY,964
120
120
  langfun/core/modalities/audio_test.py,sha256=yyGEBYqMXmNs_F2dEtj-PX8HE040vqh-YQppsvdxPw4,2025
121
- langfun/core/modalities/image.py,sha256=ovcX8NLBNv8WzxAdhQ-u4VQfHVBkWijRj_oiNwhE9lk,1768
121
+ langfun/core/modalities/image.py,sha256=9TMO63UHtkimouDb6e1naXWxbK7kRgSGPLzBY26BNk8,1835
122
122
  langfun/core/modalities/image_test.py,sha256=XMgtJXY75R5eo0CZ222D1QUy57_hESnttmCGWwDLt7k,3824
123
123
  langfun/core/modalities/mime.py,sha256=Hz6MnxQO_ccgrEryUf7dwyUGYj616I68NshLDK9PC_k,8860
124
124
  langfun/core/modalities/mime_test.py,sha256=n084tOkeKHKMOVblCmi5s8nw4o7VYn3ynqvcrz8ww7c,5977
@@ -156,8 +156,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
156
156
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
157
157
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
158
158
  langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
159
- langfun-0.1.2.dev202503250804.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
160
- langfun-0.1.2.dev202503250804.dist-info/METADATA,sha256=ZK5cXCxwd6Usf6yVEEsm0nkAJ-FfqN5Yi8aLG4-l7PI,7692
161
- langfun-0.1.2.dev202503250804.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
162
- langfun-0.1.2.dev202503250804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
163
- langfun-0.1.2.dev202503250804.dist-info/RECORD,,
159
+ langfun-0.1.2.dev202503270804.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
160
+ langfun-0.1.2.dev202503270804.dist-info/METADATA,sha256=OM2ZGwN_Fr6Rc2O1naGFgGBS-DpxbQghLkFnQcx_VEo,7692
161
+ langfun-0.1.2.dev202503270804.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
162
+ langfun-0.1.2.dev202503270804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
163
+ langfun-0.1.2.dev202503270804.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.0.2)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5