langfun 0.0.2.dev20240508__py3-none-any.whl → 0.0.2.dev20240510__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.

Potentially problematic release.


This version of langfun might be problematic. Click here for more details.

@@ -27,6 +27,7 @@ from langfun.core.llms.fake import StaticSequence
27
27
  # Gemini models.
28
28
  from langfun.core.llms.google_genai import GenAI
29
29
  from langfun.core.llms.google_genai import GeminiPro
30
+ from langfun.core.llms.google_genai import GeminiPro1_5
30
31
  from langfun.core.llms.google_genai import GeminiProVision
31
32
  from langfun.core.llms.google_genai import Palm2
32
33
  from langfun.core.llms.google_genai import Palm2_IT
@@ -34,6 +34,7 @@ class GenAI(lf.LanguageModel):
34
34
  'gemini-pro-vision',
35
35
  'text-bison-001',
36
36
  'chat-bison-001',
37
+ 'gemini-1.5-pro-latest',
37
38
  ],
38
39
  'Model name.',
39
40
  ]
@@ -262,6 +263,13 @@ _GOOGLE_GENAI_MODEL_HUB = _ModelHub()
262
263
  #
263
264
 
264
265
 
266
+ class GeminiPro1_5(GenAI): # pylint: disable=invalid-name
267
+ """Gemini Pro latest model."""
268
+
269
+ model = 'gemini-1.5-pro-latest'
270
+ multimodal = True
271
+
272
+
265
273
  class GeminiPro(GenAI):
266
274
  """Gemini Pro model."""
267
275
 
@@ -233,8 +233,9 @@ class OpenAI(lf.LanguageModel):
233
233
  for chunk in prompt.chunk():
234
234
  if isinstance(chunk, str):
235
235
  item = dict(type='text', text=chunk)
236
- elif isinstance(chunk, lf_modalities.Image) and chunk.uri:
237
- item = dict(type='image_url', image_url=dict(url=chunk.uri))
236
+ elif isinstance(chunk, lf_modalities.Image):
237
+ uri = chunk.uri or chunk.content_uri
238
+ item = dict(type='image_url', image_url=dict(url=uri))
238
239
  else:
239
240
  raise ValueError(f'Unsupported modality object: {chunk!r}.')
240
241
  content.append(item)
@@ -13,7 +13,6 @@
13
13
  # limitations under the License.
14
14
  """Image modality."""
15
15
 
16
- import base64
17
16
  import imghdr
18
17
  from typing import cast
19
18
  from langfun.core.modalities import mime
@@ -36,5 +35,4 @@ class Image(mime.MimeType):
36
35
  def _repr_html_(self) -> str:
37
36
  if self.uri and self.uri.lower().startswith(('http:', 'https:', 'ftp:')):
38
37
  return f'<img src="{self.uri}">'
39
- image_raw = base64.b64encode(self.to_bytes()).decode()
40
- return f'<img src="data:image/{self.image_format};base64,{image_raw}">'
38
+ return f'<img src="{self.content_uri}">'
@@ -14,6 +14,7 @@
14
14
  """MIME type data."""
15
15
 
16
16
  import abc
17
+ import base64
17
18
  from typing import Annotated, Union
18
19
  import langfun.core as lf
19
20
  import pyglove as pg
@@ -54,6 +55,11 @@ class MimeType(lf.Modality):
54
55
  self.rebind(content=content, skip_notification=True)
55
56
  return self.content
56
57
 
58
+ @property
59
+ def content_uri(self) -> str:
60
+ base64_content = base64.b64encode(self.to_bytes()).decode()
61
+ return f'data:{self.mime_type};base64,{base64_content}'
62
+
57
63
  @classmethod
58
64
  def from_uri(cls, uri: str, **kwargs) -> 'MimeType':
59
65
  return cls(uri=uri, content=None, **kwargs)
@@ -13,7 +13,6 @@
13
13
  # limitations under the License.
14
14
  """Video modality."""
15
15
 
16
- import base64
17
16
  from typing import cast
18
17
  from langfun.core.modalities import mime
19
18
 
@@ -40,8 +39,7 @@ class Video(mime.MimeType):
40
39
  def _repr_html_(self) -> str:
41
40
  if self.uri and self.uri.lower().startswith(('http:', 'https:', 'ftp:')):
42
41
  return f'<video controls> <source src="{self.uri}"> </video>'
43
- video_raw = base64.b64encode(self.to_bytes()).decode()
44
42
  return (
45
43
  '<video controls> <source'
46
- f' src="data:video/{self.video_format};base64,{video_raw}"> </video>'
44
+ f' src="data:video/{self.content_uri}"> </video>'
47
45
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.0.2.dev20240508
3
+ Version: 0.0.2.dev20240510
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -48,18 +48,18 @@ langfun/core/eval/patching.py,sha256=R0s2eAd1m97exQt06dmUL0V_MBG0W2Hxg7fhNB7cXW0
48
48
  langfun/core/eval/patching_test.py,sha256=8kCd54Egjju22FMgtJuxEsrXkW8ifs-UUBHtrCG1L6w,4775
49
49
  langfun/core/eval/scoring.py,sha256=1J7IATo-8FXUR0SBqk9icztHiM0lWkBFcWUo-vUURgQ,6376
50
50
  langfun/core/eval/scoring_test.py,sha256=O8olHbrUEg60gMxwOkWzKBJZpZoUlmVnBANX5Se2SXM,4546
51
- langfun/core/llms/__init__.py,sha256=1bPg1QI8duOZCYINm-jWi094x0JtLmsk4KX60qIC_gs,3245
51
+ langfun/core/llms/__init__.py,sha256=vL7po6y97askDz2p-ToSRoG2jRaA7cWbfkP9Twzwq-k,3301
52
52
  langfun/core/llms/anthropic.py,sha256=7W9YdPN3SlAFhAIQlihMkrpo7tTY_4NvD0KIlCrqcsk,8505
53
53
  langfun/core/llms/anthropic_test.py,sha256=TMM30myyEhwF99Le4RvJEXOn8RYl0q1FRkt9Q9nl1jk,5540
54
54
  langfun/core/llms/fake.py,sha256=_smsN_CsYbeWrtjpegEPwdAPV9mwaIuH_4oZGeXQwQI,2896
55
55
  langfun/core/llms/fake_test.py,sha256=ipKfdOcuqVcJ8lDXVpnBVb9HHG0hAVkFkMoHpWjC2cI,7212
56
- langfun/core/llms/google_genai.py,sha256=n8zyJwh9UCTgb6-8LyvmjVNFGZQ4-zfzZ0ulkhHAnR8,8624
56
+ langfun/core/llms/google_genai.py,sha256=nDI_Adur_K458l6EWoiiAhzjfnjRSqfTiikdu7iLPyU,8808
57
57
  langfun/core/llms/google_genai_test.py,sha256=_UcGTfl16-aDUlEWFC2W2F8y9jPUs53RBYA6MOCpGXw,7525
58
58
  langfun/core/llms/groq.py,sha256=NaGItVL_pkOpqPpI4bPGU27xLFRoaeizZ49v2s-4ERs,7844
59
59
  langfun/core/llms/groq_test.py,sha256=M6GtlrsOvDun_j-sR8cPh4W_moHWZNSTiThu3kuwbbc,5281
60
60
  langfun/core/llms/llama_cpp.py,sha256=Y_KkMUf3Xfac49koMUtUslKl3h-HWp3-ntq7Jaa3bdo,2385
61
61
  langfun/core/llms/llama_cpp_test.py,sha256=ZxC6defGd_HX9SFRU9U4cJiQnBKundbOrchbXuC1Z2M,1683
62
- langfun/core/llms/openai.py,sha256=rPwO4qPGEwbB4O7TaQD0spg_PXIfF2ioRI_ilE3Pg6Y,13257
62
+ langfun/core/llms/openai.py,sha256=u2lqYcKFjFxLfWYD0KLT3YThqcoo66rWs3n0bcuSYBs,13286
63
63
  langfun/core/llms/openai_test.py,sha256=asSA1sVy_7hnXioD_2HTxtSDpVTKBUO_EjZuyHpwbn0,14854
64
64
  langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
65
65
  langfun/core/llms/cache/base.py,sha256=cFfYvOIUae842pncqCAsRvqXCk2AnAsRYVx0mcIoAeY,3338
@@ -69,11 +69,11 @@ langfun/core/memories/__init__.py,sha256=HpghfZ-w1NQqzJXBx8Lz0daRhB2rcy2r9Xm491S
69
69
  langfun/core/memories/conversation_history.py,sha256=c9amD8hCxGFiZuVAzkP0dOMWSp8L90uvwkOejjuBqO0,1835
70
70
  langfun/core/memories/conversation_history_test.py,sha256=AaW8aNoFjxNusanwJDV0r3384Mg0eAweGmPx5DIkM0Y,2052
71
71
  langfun/core/modalities/__init__.py,sha256=ldCbs1HHAHAJECNu19vppA0sWEidI40xBs4W1F_YOlo,1073
72
- langfun/core/modalities/image.py,sha256=zNpLHwJi6PJMeeAcVQG6vn0oYIbilTuJq6xu-TvrArM,1358
72
+ langfun/core/modalities/image.py,sha256=MUqRCQYyP7Gcf3dmzjU9J9ZEpfI08gAli9ZDmk0bJEk,1254
73
73
  langfun/core/modalities/image_test.py,sha256=YxDRvC49Bjwyyndd_P7y6XjyS7dOft0Zewwxk-7q4kE,2301
74
- langfun/core/modalities/mime.py,sha256=wVfaYflhGz1W4v3m972rAplW3OGOFtjFpHDYIaUD5D0,2238
74
+ langfun/core/modalities/mime.py,sha256=RatBOPqYEneYMe-lfgRxJp5T3yvgV6vBMNY8lK2WU8k,2421
75
75
  langfun/core/modalities/mime_test.py,sha256=cVHxRvJ1QXC1SVhBmWkJdWGpL9Xl0UNfTQq6j0OGGL4,1881
76
- langfun/core/modalities/video.py,sha256=25M4XsNG5XEWRy57LYT_a6_aMURMPAgC41B3weEXFsY,1747
76
+ langfun/core/modalities/video.py,sha256=bzJLeBDF6FIVHyrAvRqYcQq2pCLBqN-UIgX_f3lM3E0,1654
77
77
  langfun/core/modalities/video_test.py,sha256=jYuI2m8S8zDCAVBPEUbbpP205dXAht90A2_PHWo4-r8,2039
78
78
  langfun/core/structured/__init__.py,sha256=Qg1ocwsb60od8fJky3F3JAOhwjwT9WA7IX3C2j2s3zA,3707
79
79
  langfun/core/structured/completion.py,sha256=skBxt6V_fv2TBUKnzFgnPMbVY8HSYn8sY04MLok2yvs,7299
@@ -103,8 +103,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
103
103
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
104
104
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
105
105
  langfun/core/templates/selfplay_test.py,sha256=DYVrkk7uNKCqJGEHH31HssU2BPuMItU1vJLzfcXIlYg,2156
106
- langfun-0.0.2.dev20240508.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
107
- langfun-0.0.2.dev20240508.dist-info/METADATA,sha256=-kG5pyZ6wAFJRP0hINq-JUhoEnKJsXrn2YCZbZuAFhY,3405
108
- langfun-0.0.2.dev20240508.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
109
- langfun-0.0.2.dev20240508.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
110
- langfun-0.0.2.dev20240508.dist-info/RECORD,,
106
+ langfun-0.0.2.dev20240510.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
107
+ langfun-0.0.2.dev20240510.dist-info/METADATA,sha256=i3GbZdlj9VmCk3pLkMXNE5mDHvWAASCD8OGBeEiz1Es,3405
108
+ langfun-0.0.2.dev20240510.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
109
+ langfun-0.0.2.dev20240510.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
110
+ langfun-0.0.2.dev20240510.dist-info/RECORD,,