langfun 0.1.1.dev20240730__py3-none-any.whl → 0.1.1.dev20240802__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.
langfun/core/eval/base.py CHANGED
@@ -542,6 +542,8 @@ class Evaluable(lf.Component):
542
542
  'padding: 10px; border: 1px solid; margin-top: 10px">'
543
543
  )
544
544
  s.write(html.escape(m.get('formatted_text', m.text)))
545
+
546
+ # Write output.
545
547
  if m.result is not None:
546
548
  s.write(
547
549
  '<div style="color: magenta; white-space: pre-wrap;'
@@ -549,6 +551,23 @@ class Evaluable(lf.Component):
549
551
  )
550
552
  s.write(html.escape(pg.format(m.result)))
551
553
  s.write('</div>')
554
+
555
+ # Write modality information.
556
+ if 'lm-input' in m.tags or 'lm-response' in m.tags:
557
+ modalities = m.referred_modalities()
558
+ if modalities:
559
+ s.write(f'<div style="color: {text_color}; white-space: pre-wrap;'
560
+ 'padding: 10px; border: 1px solid; margin-top: 10px"><table>')
561
+ for name, modality in modalities.items():
562
+ s.write(f'<tr><td>{name}</td><td>')
563
+ if hasattr(modality, '_repr_html_'):
564
+ s.write(modality._repr_html_()) # pylint: disable=protected-access
565
+ else:
566
+ s.write(html.escape(pg.format(modality, max_bytes_len=32)))
567
+ s.write('</td></tr>')
568
+ s.write('</table></div>')
569
+
570
+ # Write usage information.
552
571
  if m.metadata.get('usage', None):
553
572
  s.write(
554
573
  '<div style="background-color: #EEEEEE; color: black; '
@@ -271,9 +271,9 @@ class Matching(base.Evaluation):
271
271
  for i, (example, output, message) in enumerate(self.matches):
272
272
  bgcolor = 'white' if i % 2 == 0 else '#DDDDDD'
273
273
  s.write(f'<tr style="background-color: {bgcolor}"><td>{i + 1}</td>')
274
- input_str = pg.format(example, verbose=False)
274
+ input_str = pg.format(example, verbose=False, max_bytes_len=32)
275
275
  s.write(f'<td style="color:green;white-space:pre-wrap">{input_str}</td>')
276
- output_str = pg.format(output, verbose=False)
276
+ output_str = pg.format(output, verbose=False, max_bytes_len=32)
277
277
  s.write(f'<td style="color:blue;white-space:pre-wrap">{output_str}</td>')
278
278
  s.write('<td>')
279
279
  self._render_message(message, s)
@@ -296,9 +296,9 @@ class Matching(base.Evaluation):
296
296
  for i, (example, output, message) in enumerate(self.mismatches):
297
297
  bgcolor = 'white' if i % 2 == 0 else '#DDDDDD'
298
298
  s.write(f'<tr style="background-color: {bgcolor}"><td>{i + 1}</td>')
299
- input_str = pg.format(example, verbose=False)
299
+ input_str = pg.format(example, verbose=False, max_bytes_len=32)
300
300
  s.write(f'<td style="color:green;white-space:pre-wrap">{input_str}</td>')
301
- output_str = pg.format(output, verbose=False)
301
+ output_str = pg.format(output, verbose=False, max_bytes_len=32)
302
302
  s.write(
303
303
  f'<td style="color:magenta;white-space:pre-wrap">{output_str}</td>'
304
304
  )
@@ -196,9 +196,9 @@ class Scoring(base.Evaluation):
196
196
  for i, (example, output, score, message) in enumerate(self.scored):
197
197
  bgcolor = 'white' if i % 2 == 0 else '#DDDDDD'
198
198
  s.write(f'<tr style="background-color: {bgcolor}"><td>{i + 1}</td>')
199
- input_str = pg.format(example, verbose=False)
199
+ input_str = pg.format(example, verbose=False, max_bytes_len=32)
200
200
  s.write(f'<td style="color:green;white-space:pre-wrap">{input_str}</td>')
201
- output_str = pg.format(output, verbose=False)
201
+ output_str = pg.format(output, verbose=False, max_bytes_len=32)
202
202
  s.write(f'<td style="color:blue;white-space:pre-wrap">{output_str}</td>')
203
203
  s.write(f'<td style="color:magenta;white-space:pre-wrap">{score}</td>')
204
204
  s.write('<td>')
@@ -39,6 +39,8 @@ from langfun.core.llms.google_genai import Palm2_IT
39
39
  # OpenAI models.
40
40
  from langfun.core.llms.openai import OpenAI
41
41
 
42
+ from langfun.core.llms.openai import Gpt4oMini
43
+ from langfun.core.llms.openai import Gpt4oMini_20240718
42
44
  from langfun.core.llms.openai import Gpt4o
43
45
  from langfun.core.llms.openai import Gpt4o_20240513
44
46
 
@@ -34,6 +34,8 @@ SUPPORTED_MODELS_AND_SETTINGS = {
34
34
  # Models from https://platform.openai.com/docs/models
35
35
  # RPM is from https://platform.openai.com/docs/guides/rate-limits
36
36
  # GPT-4o models
37
+ 'gpt-4o-mini': pg.Dict(rpm=10000, tpm=5000000),
38
+ 'gpt-4o-mini-2024-07-18': pg.Dict(rpm=10000, tpm=5000000),
37
39
  'gpt-4o': pg.Dict(rpm=10000, tpm=5000000),
38
40
  'gpt-4o-2024-05-13': pg.Dict(rpm=10000, tpm=5000000),
39
41
  # GPT-4-Turbo models
@@ -347,6 +349,18 @@ class Gpt4_32K_20230613(Gpt4_32K): # pylint:disable=invalid-name
347
349
  model = 'gpt-4-32k-0613'
348
350
 
349
351
 
352
+ class Gpt4oMini(OpenAI):
353
+ """GPT-4o Mini."""
354
+ model = 'gpt-4o-mini'
355
+ multimodal = True
356
+
357
+
358
+ class Gpt4oMini_20240718(OpenAI): # pylint:disable=invalid-name
359
+ """GPT-4o Mini."""
360
+ model = 'gpt-4o-mini-2024-07-18'
361
+ multimodal = True
362
+
363
+
350
364
  class Gpt4o(OpenAI):
351
365
  """GPT-4o."""
352
366
  model = 'gpt-4o'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.1.1.dev20240730
3
+ Version: 0.1.1.dev20240802
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -44,15 +44,15 @@ langfun/core/coding/python/parsing_test.py,sha256=9vAWF484kWIm6JZq8NFiMgKUDhXV-d
44
44
  langfun/core/coding/python/permissions.py,sha256=1QWGHvzL8MM0Ok_auQ9tURqZHtdOfJaDpBzZ29GUE-c,2544
45
45
  langfun/core/coding/python/permissions_test.py,sha256=w5EDb8QxpxgJyZkojyzVWQvDfg366zn99-g__6TbPQ0,2699
46
46
  langfun/core/eval/__init__.py,sha256=Evt-E4FEhZF2tXL6-byh_AyA7Cc_ZoGmvnN7vkAZedk,1898
47
- langfun/core/eval/base.py,sha256=qZNnI89xbpP_jKthGe6LmS08VWFb1MfF2J6MtoHiTJw,74429
47
+ langfun/core/eval/base.py,sha256=zZgebhUubX-149VkwkyQBKkTyv5hF0ubjj9eBd2baLo,75201
48
48
  langfun/core/eval/base_test.py,sha256=cHOTIWVW4Dp8gKKIKcZrAcJ-w84j2GIozTzJoiAX7p4,26743
49
- langfun/core/eval/matching.py,sha256=jJy5YRARPwg4xchWQWMyBIQ-GoCZzfoFpMX8NjOFTnE,9690
49
+ langfun/core/eval/matching.py,sha256=9GX8HfO9jKxgNLAivgy5K88Xhoh6Z7Pptq65pe7vht8,9762
50
50
  langfun/core/eval/matching_test.py,sha256=f7iVyXH5KGJBWt4Wp14Bt9J3X59A6Ayfog9MbuFvPew,5532
51
51
  langfun/core/eval/patching.py,sha256=R0s2eAd1m97exQt06dmUL0V_MBG0W2Hxg7fhNB7cXW0,3866
52
52
  langfun/core/eval/patching_test.py,sha256=8kCd54Egjju22FMgtJuxEsrXkW8ifs-UUBHtrCG1L6w,4775
53
- langfun/core/eval/scoring.py,sha256=sDb0MuwEtkbAZOGzZ-gxtLdFtzWBHh-Kl8qGmKlWdNo,6350
53
+ langfun/core/eval/scoring.py,sha256=AlCwEVrU6nvURDB1aPxA2XBUmOjWxuNJDXJoS4-6VbU,6386
54
54
  langfun/core/eval/scoring_test.py,sha256=O8olHbrUEg60gMxwOkWzKBJZpZoUlmVnBANX5Se2SXM,4546
55
- langfun/core/llms/__init__.py,sha256=sRD_PjfD5wKuzANCOCjChjuZHUn2Q1WruZeVflqej5M,4609
55
+ langfun/core/llms/__init__.py,sha256=YGILcGi2QTxDG0v-0Gd4uAj1HL_zRhtllOM9EURxzDg,4712
56
56
  langfun/core/llms/anthropic.py,sha256=Gon3fOi31RhZFgNd0ijyTnKnUdp9hrWrCoSXyO4UaLw,7316
57
57
  langfun/core/llms/anthropic_test.py,sha256=T-swuMkfnlgs8Fpif4rtXs579exGk0TsbLMirXDZCkg,5533
58
58
  langfun/core/llms/fake.py,sha256=Dd7-6ka9pFf3fcWZyczamjOqQ91MOI-m7We3Oc9Ffmo,2927
@@ -63,7 +63,7 @@ langfun/core/llms/groq.py,sha256=pqtyOZ_1_OJMOg8xATWT_B_SVbuT9nMRf4VkH9GzW8g,630
63
63
  langfun/core/llms/groq_test.py,sha256=GYF_Qtq5S1H1TrKH38t6_lkdroqT7v-joYLDKnmS9e0,5274
64
64
  langfun/core/llms/llama_cpp.py,sha256=9tXQntSCDtjTF3bnyJrAPCr4N6wycy5nXYvp9uduygE,2843
65
65
  langfun/core/llms/llama_cpp_test.py,sha256=MWO_qaOeKjRniGjcaWPDScd7HPaIJemqUZoslrt4FPs,1806
66
- langfun/core/llms/openai.py,sha256=0z9qIH9FlWj9VWUnhOX321T6JHO-vjY2IozT7OVI4GY,13654
66
+ langfun/core/llms/openai.py,sha256=jILxfFb3vBuyf1u_2-LVfs_wekPF2RVuNFzNVg25pEA,14004
67
67
  langfun/core/llms/openai_test.py,sha256=3muDTnW7UBOSHq694Fi2bofqhe8Pkj0Tl8IShoLCTOM,15525
68
68
  langfun/core/llms/rest.py,sha256=laopuq-zD8V-3Y6eFDngftHEbE66VlUkCD2-rvvRaLU,3388
69
69
  langfun/core/llms/rest_test.py,sha256=NZ3Nf0XQVpT9kLP5cBVo_yBHLI7vWTYhWQxYEJVMGs4,3472
@@ -117,8 +117,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
117
117
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
118
118
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
119
119
  langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
120
- langfun-0.1.1.dev20240730.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
121
- langfun-0.1.1.dev20240730.dist-info/METADATA,sha256=g9OiRFzhLhJmZNWlBX0oRQOTvMXVUHXW0yCkhXpARDE,5247
122
- langfun-0.1.1.dev20240730.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
123
- langfun-0.1.1.dev20240730.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
124
- langfun-0.1.1.dev20240730.dist-info/RECORD,,
120
+ langfun-0.1.1.dev20240802.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
121
+ langfun-0.1.1.dev20240802.dist-info/METADATA,sha256=at_-rWCFGnuEwPrybUGaJo7XNUnRvYdWL-Q0SrivPQ0,5247
122
+ langfun-0.1.1.dev20240802.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
123
+ langfun-0.1.1.dev20240802.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
124
+ langfun-0.1.1.dev20240802.dist-info/RECORD,,