langfun 0.1.2.dev202501060804__py3-none-any.whl → 0.1.2.dev202501100804__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.
Files changed (39) hide show
  1. langfun/core/__init__.py +0 -5
  2. langfun/core/coding/python/correction.py +4 -3
  3. langfun/core/coding/python/errors.py +10 -9
  4. langfun/core/coding/python/execution.py +23 -12
  5. langfun/core/coding/python/execution_test.py +21 -2
  6. langfun/core/coding/python/generation.py +18 -9
  7. langfun/core/concurrent.py +2 -3
  8. langfun/core/console.py +8 -3
  9. langfun/core/eval/base.py +2 -3
  10. langfun/core/eval/v2/reporting.py +8 -4
  11. langfun/core/language_model.py +7 -4
  12. langfun/core/language_model_test.py +15 -0
  13. langfun/core/llms/__init__.py +7 -0
  14. langfun/core/llms/deepseek.py +117 -0
  15. langfun/core/llms/deepseek_test.py +61 -0
  16. langfun/core/llms/google_genai.py +1 -0
  17. langfun/core/llms/groq.py +12 -99
  18. langfun/core/llms/groq_test.py +31 -137
  19. langfun/core/llms/llama_cpp.py +17 -54
  20. langfun/core/llms/llama_cpp_test.py +2 -34
  21. langfun/core/llms/openai.py +14 -147
  22. langfun/core/llms/openai_compatible.py +179 -0
  23. langfun/core/llms/openai_compatible_test.py +480 -0
  24. langfun/core/llms/openai_test.py +13 -423
  25. langfun/core/llms/vertexai.py +6 -2
  26. langfun/core/llms/vertexai_test.py +1 -1
  27. langfun/core/modalities/mime.py +8 -0
  28. langfun/core/modalities/mime_test.py +19 -4
  29. langfun/core/modality_test.py +0 -1
  30. langfun/core/structured/mapping.py +13 -13
  31. langfun/core/structured/mapping_test.py +2 -2
  32. langfun/core/structured/schema.py +16 -8
  33. {langfun-0.1.2.dev202501060804.dist-info → langfun-0.1.2.dev202501100804.dist-info}/METADATA +13 -2
  34. {langfun-0.1.2.dev202501060804.dist-info → langfun-0.1.2.dev202501100804.dist-info}/RECORD +37 -35
  35. {langfun-0.1.2.dev202501060804.dist-info → langfun-0.1.2.dev202501100804.dist-info}/WHEEL +1 -1
  36. langfun/core/text_formatting.py +0 -168
  37. langfun/core/text_formatting_test.py +0 -65
  38. {langfun-0.1.2.dev202501060804.dist-info → langfun-0.1.2.dev202501100804.dist-info}/LICENSE +0 -0
  39. {langfun-0.1.2.dev202501060804.dist-info → langfun-0.1.2.dev202501100804.dist-info}/top_level.txt +0 -0
@@ -91,20 +91,25 @@ class SchemaError(Exception): # pylint: disable=g-bad-exception-name
91
91
  def __str__(self):
92
92
  r = io.StringIO()
93
93
  r.write(
94
- lf.colored(f'{self.cause.__class__.__name__}: {self.cause}', 'magenta'))
94
+ pg.colored(
95
+ f'{self.cause.__class__.__name__}: {self.cause}', 'magenta'
96
+ )
97
+ )
95
98
 
96
99
  r.write('\n')
97
- r.write(lf.colored('Schema:', 'red'))
100
+ r.write(pg.colored('Schema:', 'red'))
98
101
  r.write('\n\n')
99
102
  r.write(textwrap.indent(
100
- lf.colored(schema_repr(self.protocol).repr(self.schema), 'magenta'),
103
+ pg.colored(
104
+ schema_repr(self.protocol).repr(self.schema), 'magenta'
105
+ ),
101
106
  ' ' * 2
102
107
  ))
103
108
  r.write('\n\n')
104
- r.write(lf.colored('Generated value:', 'red'))
109
+ r.write(pg.colored('Generated value:', 'red'))
105
110
  r.write('\n\n')
106
111
  r.write(textwrap.indent(
107
- lf.colored(value_repr(self.protocol).repr(self.value), 'magenta'),
112
+ pg.colored(value_repr(self.protocol).repr(self.value), 'magenta'),
108
113
  ' ' * 2
109
114
  ))
110
115
  return r.getvalue()
@@ -759,12 +764,15 @@ class JsonError(Exception):
759
764
  def __str__(self) -> str:
760
765
  r = io.StringIO()
761
766
  r.write(
762
- lf.colored(f'{self.cause.__class__.__name__}: {self.cause}', 'magenta'))
767
+ pg.colored(
768
+ f'{self.cause.__class__.__name__}: {self.cause}', 'magenta'
769
+ )
770
+ )
763
771
 
764
772
  r.write('\n\n')
765
- r.write(lf.colored('JSON text:', 'red'))
773
+ r.write(pg.colored('JSON text:', 'red'))
766
774
  r.write('\n\n')
767
- r.write(textwrap.indent(lf.colored(self.json, 'magenta'), ' ' * 2))
775
+ r.write(textwrap.indent(pg.colored(self.json, 'magenta'), ' ' * 2))
768
776
  return r.getvalue()
769
777
 
770
778
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: langfun
3
- Version: 0.1.2.dev202501060804
3
+ Version: 0.1.2.dev202501100804
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -56,6 +56,17 @@ Requires-Dist: pillow>=10.0.0; extra == "mime-pil"
56
56
  Provides-Extra: mime-xlsx
57
57
  Requires-Dist: openpyxl>=3.1.0; extra == "mime-xlsx"
58
58
  Requires-Dist: pandas>=2.0.3; extra == "mime-xlsx"
59
+ Dynamic: author
60
+ Dynamic: author-email
61
+ Dynamic: classifier
62
+ Dynamic: description
63
+ Dynamic: description-content-type
64
+ Dynamic: home-page
65
+ Dynamic: keywords
66
+ Dynamic: license
67
+ Dynamic: provides-extra
68
+ Dynamic: requires-dist
69
+ Dynamic: summary
59
70
 
60
71
  <div align="center">
61
72
  <img src="https://raw.githubusercontent.com/google/langfun/main/docs/_static/logo.svg" width="520px" alt="logo"></img>
@@ -1,22 +1,22 @@
1
1
  langfun/__init__.py,sha256=fhfPXpHN7GoGqixpFfqhQkYxFs_siP_LhbjZhd3lhio,2497
2
- langfun/core/__init__.py,sha256=oboXhlpA93wk4p1K52-tx0pbBt49r6Y1aCmiavBV03Y,4830
2
+ langfun/core/__init__.py,sha256=1fHngxhnpxYaVzNMPnifU2JXKaC4LdJGTGp0VnbaXUo,4580
3
3
  langfun/core/component.py,sha256=HVrEoTL1Y01iqOHC3FYdbAOnffqfHHtGJXoK1vkdEwo,11583
4
4
  langfun/core/component_test.py,sha256=sG-T2wpvBfHqWGZE7sc4NayJj2aj5QFBzSwFiwrGEIc,10376
5
- langfun/core/concurrent.py,sha256=QMNYhB_PyjvVJtabMokpzotZRYvyE9iYu2QsgwDk7M4,29552
5
+ langfun/core/concurrent.py,sha256=zhZX-YpByUKXWwarlDZFfY8TMW4r71jSW_wDlLhB980,29485
6
6
  langfun/core/concurrent_test.py,sha256=ILlAjfhV84yJfY1QLe3N9aYry1sCjY-ywfIlXGafenI,17336
7
- langfun/core/console.py,sha256=Fra2_MSWZbFh6rY8HZoYgpGLsrNvhaGuL03znOwQbhM,2529
7
+ langfun/core/console.py,sha256=bGwuJZRs_9NNKY1KmJjIZLeoQ_fL0BikAJPLDVdp1hw,2558
8
8
  langfun/core/console_test.py,sha256=pBOcuNMJdVELywvroptfcRtJMsegMm3wSlHAL2TdxVk,1679
9
9
  langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,11140
10
10
  langfun/core/langfunc_test.py,sha256=fKIAqcSNI_7M6nwoZW77HEam8Oa6vcWhsCNgVJanzb4,8822
11
- langfun/core/language_model.py,sha256=b15MZ_qbydnz5vQ09t7sf9tc3C7qWvMSxUrGfT0p99I,33827
12
- langfun/core/language_model_test.py,sha256=hnYhtw7GM_TbhgsJzHNYTaoDewUlPHpOVlI7xEkCFuI,31783
11
+ langfun/core/language_model.py,sha256=lQFHIEAHMNZtKNQ5tG6Gb74dGcfvy5mA4eeftYhnEOg,33881
12
+ langfun/core/language_model_test.py,sha256=lFPXBcxofvvL6u5GEpAAbsPxIDmk0Wy038SQ_mBIOz8,32153
13
13
  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=16oiMpg9O9VKrgpfrvJrfvga3n3FzUuD_zdWb9nvSWA,25686
17
17
  langfun/core/message_test.py,sha256=jtZoNBNbA99i2fjoKg5vTRgoUe84J4MH8ZMGakGmTHs,32577
18
18
  langfun/core/modality.py,sha256=K8pUGuMpfWcOtVcXC_OqVjro1-RhHF6ddQni61DuYzM,4166
19
- langfun/core/modality_test.py,sha256=7SwhixFME2Q1sIXRgJx97EZFiIyC31A9NVr6_nDtFv4,2441
19
+ langfun/core/modality_test.py,sha256=0WL_yd3B4K-FviWdSpDnOwj0f9TQI0v9t6X0vWvvJbo,2415
20
20
  langfun/core/natural_language.py,sha256=3ynSnaYQnjE60LIPK5fyMgdIjubnPYZwzGq4rWPeloE,1177
21
21
  langfun/core/natural_language_test.py,sha256=LHGU_1ytbkGuSZQFIFP7vP3dBlcY4-A12fT6dbjUA0E,1424
22
22
  langfun/core/sampling.py,sha256=SCnS5PFJWNVxSKvSkSCNRUmruvScun8UcNN4gafuXcw,5866
@@ -25,8 +25,6 @@ langfun/core/subscription.py,sha256=euawEuSZP-BHydaT-AQpfYFL0m5pWPGcW0upFhrojqc,
25
25
  langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIcArBo,8717
26
26
  langfun/core/template.py,sha256=jNhYSrbLIn9kZOa03w5QZbyjgfnzJzE_ZrrMvvWY4t4,24929
27
27
  langfun/core/template_test.py,sha256=g7x4mgNIAXEEj-4W1D5whGfl5YikLEQoylKPzaeDomk,17069
28
- langfun/core/text_formatting.py,sha256=d7t9vaY6aCn1dkfkikpNYnBy5E_i93vHbfyDWFclGZU,5284
29
- langfun/core/text_formatting_test.py,sha256=ck0Xzdd4YF4CtCUj7VE0GybfbAyKQ8p3xkM1FBGrqIk,2096
30
28
  langfun/core/agentic/__init__.py,sha256=ndoDX0sAYsa3eVdXuu6nB-a-BH5TaK3urW6zAaFiyVs,1110
31
29
  langfun/core/agentic/action.py,sha256=yW5-2NRHIrQmmQEYmL83aIdSwaRfUez9mqCbME_aBWQ,25391
32
30
  langfun/core/agentic/action_eval.py,sha256=ZtjTh34S7XPIUqandQ0YwAtzw-S7ofuZ7rRXnRbUMdQ,4424
@@ -34,20 +32,20 @@ langfun/core/agentic/action_eval_test.py,sha256=tRUkWmOE9p0rpNOq19xAY2oDEnYsEEyk
34
32
  langfun/core/agentic/action_test.py,sha256=Gu7P5XQvzqbKawn2jjyTpWaARzzhzO04KkC1TuBnUnw,4612
35
33
  langfun/core/coding/__init__.py,sha256=5utju_fwEsImaiftx4oXKl9FAM8p281k8-Esdh_-m1w,835
36
34
  langfun/core/coding/python/__init__.py,sha256=MJ-vubliz-ebrZH3OBRKBwMi0S9-FrhGCp8YQLR6_I4,1776
37
- langfun/core/coding/python/correction.py,sha256=cg5intTKlx7Lr4VGU-qc90_qF2nuat1mpIAcGj-JmNw,7018
35
+ langfun/core/coding/python/correction.py,sha256=SR_ZP8MYqvipFi5Scsl_5FYzBRRTwRehig79r67ZdlM,7129
38
36
  langfun/core/coding/python/correction_test.py,sha256=qGxXuHaO32onF6cAoTfO1_sH_lM7-3dE9UqaaU8Myxs,4215
39
- langfun/core/coding/python/errors.py,sha256=fX3Du63uGm25YFXW9D-bV2gntTdTAX3hBFtAnRlmg14,3166
37
+ langfun/core/coding/python/errors.py,sha256=KDn0bJH-34dUM5fp3Ocgn3HvWg1XYgFnxCSiWXGNI1c,3162
40
38
  langfun/core/coding/python/errors_test.py,sha256=_ZbWJCFIb-FkCK7K1zCuH8W3x_NFt-jNe3dfP8yqaD4,2323
41
- langfun/core/coding/python/execution.py,sha256=raZix62g2fwt6Lgykll2DFzkLlEjVqN9E73q0iaVdak,10185
42
- langfun/core/coding/python/execution_test.py,sha256=lExY6GMLeuCsCKXgM2KbAPJ6kqSlfHmz3RG0-dqfVcI,7197
43
- langfun/core/coding/python/generation.py,sha256=xivSeOKGN00HnG1TLuFhPfP-JyRuRrSELxVJW2ngqIQ,7750
39
+ langfun/core/coding/python/execution.py,sha256=vf8AzDcL_9xh-kpTKWywt9gV7Pc8KLghOHj6hrpiqS8,10762
40
+ langfun/core/coding/python/execution_test.py,sha256=xBsk5OZuuEY1_w7dxu25akL-NVHm02xjzyOQ2rPWhgY,7693
41
+ langfun/core/coding/python/generation.py,sha256=MqzoFdB3v7BtrAzqIMMyH8RvqaNJ6TSqZ9Xw-iPmPTI,8427
44
42
  langfun/core/coding/python/generation_test.py,sha256=54bgKr1DgzYFLoqR8bTn7Yjol0gPCuR6XvRltR4l6YM,2777
45
43
  langfun/core/coding/python/parsing.py,sha256=LMg8REP4VDY0YQjtPAGNAW4rKlMNdSXF8m19wMT9yrY,7128
46
44
  langfun/core/coding/python/parsing_test.py,sha256=9vAWF484kWIm6JZq8NFiMgKUDhXV-deRl1QMmNERfAA,7386
47
45
  langfun/core/coding/python/permissions.py,sha256=1QWGHvzL8MM0Ok_auQ9tURqZHtdOfJaDpBzZ29GUE-c,2544
48
46
  langfun/core/coding/python/permissions_test.py,sha256=w5EDb8QxpxgJyZkojyzVWQvDfg366zn99-g__6TbPQ0,2699
49
47
  langfun/core/eval/__init__.py,sha256=OEXr1ZRuvLuhJJfuQ1ZWQ-SvYzjyrtiAAEogYaB7E6o,1933
50
- langfun/core/eval/base.py,sha256=ajHUS_BdzBIDKEwAmMzne0lJi8HcDhPmyw_plO0p7G0,75814
48
+ langfun/core/eval/base.py,sha256=XXerMVkK4wREo7K1_aCyay6vDjw3mfs389XThAdzv50,75768
51
49
  langfun/core/eval/base_test.py,sha256=-LsIV9DXlDal0EnOlaWpibJvfef0NbxtZAm0OH_abAE,27189
52
50
  langfun/core/eval/matching.py,sha256=AVKkGoc-BaHEzgSBamaAk3194TgqckDe_dinpS6LrXI,9323
53
51
  langfun/core/eval/matching_test.py,sha256=QCoYEuf4b_1bkHqUCuRzKMbXHrV3AB2FCOBivo1stC4,5249
@@ -73,31 +71,35 @@ langfun/core/eval/v2/progress.py,sha256=azZgssQgNdv3IgjKEaQBuGI5ucFDNbdi02P4z_nQ
73
71
  langfun/core/eval/v2/progress_test.py,sha256=YU7VHzmy5knPZwj9vpBN3rQQH2tukj9eKHkuBCI62h8,2540
74
72
  langfun/core/eval/v2/progress_tracking.py,sha256=l9fEkz4oP5McpZzf72Ua7PYm3lAWtRru7gRWNf8H0ms,6083
75
73
  langfun/core/eval/v2/progress_tracking_test.py,sha256=fouMVJkFJqHjbhQJngGLGCmA9x3n0dU4USI2dY163mg,2291
76
- langfun/core/eval/v2/reporting.py,sha256=obYPQma5k4K3jxTmV8UXigJnQZvWfxUENBwoa-29JSk,8265
74
+ langfun/core/eval/v2/reporting.py,sha256=QOp5jX761Esvi5w_UIRLDqPY_XRO6ru02-DOrdqVK_4,8392
77
75
  langfun/core/eval/v2/reporting_test.py,sha256=UmYSAQvD3AIXsSyWQ-WD2uLtEISYpmBeoKY5u5Qwc8E,5696
78
76
  langfun/core/eval/v2/runners.py,sha256=DKEmSlGXjOXKWFdBhTpLy7tMsBHZHd1Brl3hWIngsSQ,15931
79
77
  langfun/core/eval/v2/runners_test.py,sha256=A37fKK2MvAVTiShsg_laluJzJ9AuAQn52k7HPbfD0Ks,11666
80
- langfun/core/llms/__init__.py,sha256=hzddKJKI7NsqGXXyV3Q2jhB95A0TTpBIAhKrACICkk0,6519
78
+ langfun/core/llms/__init__.py,sha256=Ntr0kvHc17VEZ5EV9fCoYY1kzRvQxCoZrtDRYNiMWCs,6742
81
79
  langfun/core/llms/anthropic.py,sha256=a5MmnFsBA0CbfvwzXT1v_0fqLRMrhUNdh1tx6469PQ4,14357
82
80
  langfun/core/llms/anthropic_test.py,sha256=-2U4kc_pgBM7wqxu8RuxzyHPGww1EAWqKUvN4PW8Btw,8058
83
81
  langfun/core/llms/compositional.py,sha256=csW_FLlgL-tpeyCOTVvfUQkMa_zCN5Y2I-YbSNuK27U,2872
84
82
  langfun/core/llms/compositional_test.py,sha256=4eTnOer-DncRKGaIJW2ZQQMLnt5r2R0UIx_DYOvGAQo,2027
83
+ langfun/core/llms/deepseek.py,sha256=Y7DlLUWrukbPVyBMesppd-m75Q-PxD0b3KnMKaoY_8I,3744
84
+ langfun/core/llms/deepseek_test.py,sha256=dS72i52bwMpCN4dJDvpJI59AnNChpwxS5eYYFrhGh90,1843
85
85
  langfun/core/llms/fake.py,sha256=gCHBYBLvBCsC78HI1hpoqXCS-p1FMTgY1P1qh_sGBPk,3070
86
86
  langfun/core/llms/fake_test.py,sha256=2h13qkwEz_JR0mtUDPxdAhQo7MueXaFSwsD2DIRDW9g,7653
87
87
  langfun/core/llms/gemini.py,sha256=tfM4vrt0WnvnrxRhWXZWh7Gp8dYYfMnSbi9uOstkSak,17399
88
88
  langfun/core/llms/gemini_test.py,sha256=2ERhYWCJwnfDTQbCaZHFuB1TdWJFrOBS7yyCBInIdQk,6129
89
- langfun/core/llms/google_genai.py,sha256=p19jTO3D-wNUIxDcLwypgGpTCjvwQxqxCMBoPjtaetM,3645
89
+ langfun/core/llms/google_genai.py,sha256=85Vmx5QmsziON03PRsFQINSu5NF6pAAuFFhUdDteWGc,3662
90
90
  langfun/core/llms/google_genai_test.py,sha256=JZf_cbQ4GGGpwiQCLjFJn7V4jxBBqgZhIx91AzbGKVo,1250
91
- langfun/core/llms/groq.py,sha256=dCnR3eAECEKuKKAAj-PDTs8NRHl6CQPdf57m1f6a79U,10312
92
- langfun/core/llms/groq_test.py,sha256=GYF_Qtq5S1H1TrKH38t6_lkdroqT7v-joYLDKnmS9e0,5274
93
- langfun/core/llms/llama_cpp.py,sha256=9tXQntSCDtjTF3bnyJrAPCr4N6wycy5nXYvp9uduygE,2843
94
- langfun/core/llms/llama_cpp_test.py,sha256=MWO_qaOeKjRniGjcaWPDScd7HPaIJemqUZoslrt4FPs,1806
95
- langfun/core/llms/openai.py,sha256=dLDVBB47nJ30XCwjJpAZMc55ZlZXB__PcfcICCRNuXQ,20995
96
- langfun/core/llms/openai_test.py,sha256=kOWa1nf-nJvtYY10REUw5wojh3ZgfU8tRaCZ8wUgJbA,16623
91
+ langfun/core/llms/groq.py,sha256=oGxyyCi5TtMVu2POdO8pXS7pK4Es56FtqjghZIGYopc,7579
92
+ langfun/core/llms/groq_test.py,sha256=9aOD3nO4dEoH57B-5iOr5DQjG0vyv1jzFtAe7HfoiNg,1963
93
+ langfun/core/llms/llama_cpp.py,sha256=Z7P3gc4xeIjc2bX0Ey1y5EUYJVMnMa2Q67PZ9iye9sE,1409
94
+ langfun/core/llms/llama_cpp_test.py,sha256=wfTO7nmUwL65U2kK9P9fcMt92JjNDuVia4G1E7znf_4,1086
95
+ langfun/core/llms/openai.py,sha256=CHUg8c0FE30LZkhvj0Kc8w0oqckbZhrp45GA94HWPs8,16614
96
+ langfun/core/llms/openai_compatible.py,sha256=MF9JCc0uTPkIK95uvQTMIBXk4z_xKQMZqQHFaVmXwcA,5898
97
+ langfun/core/llms/openai_compatible_test.py,sha256=TSEKhwy7eg-BW5tgRHwoprngE4j5F9HzEVuRoPK8sWw,16183
98
+ langfun/core/llms/openai_test.py,sha256=m85YjGCvWvV5ZYagjC0FqI0FcqyCEVCbUUs8Wm3iUrc,2475
97
99
  langfun/core/llms/rest.py,sha256=sWbYUV8S3SuOg9giq7xwD-xDRfaF7NP_ig7bI52-Rj4,3442
98
100
  langfun/core/llms/rest_test.py,sha256=NZ3Nf0XQVpT9kLP5cBVo_yBHLI7vWTYhWQxYEJVMGs4,3472
99
- langfun/core/llms/vertexai.py,sha256=D9pC-zNRTZ4LDZeV_tjP_c8y3JaGQxTOXpp8VIthwCI,5420
100
- langfun/core/llms/vertexai_test.py,sha256=KqQkJpjZvpqp-JmDK2yTYK_XyLIyizzb4EeTHfUV8sk,1779
101
+ langfun/core/llms/vertexai.py,sha256=MuwLPTJ6-9x2uRDCSM1_biPK6M76FFlL1ezf5OmobDA,5504
102
+ langfun/core/llms/vertexai_test.py,sha256=iXjmQs7TNiwcueoaRGpdp4KnASkDJaTP__Z9QroN8zQ,1787
101
103
  langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
102
104
  langfun/core/llms/cache/base.py,sha256=rt3zwmyw0y9jsSGW-ZbV1vAfLxQ7_3AVk0l2EySlse4,3918
103
105
  langfun/core/llms/cache/in_memory.py,sha256=i58oiQL28RDsq37dwqgVpC2mBETJjIEFS20yHiV5MKU,5185
@@ -110,8 +112,8 @@ langfun/core/modalities/audio.py,sha256=qCrVCX690SG0ps-ZfOtNWvHn_CmdJsmxF7GySScW
110
112
  langfun/core/modalities/audio_test.py,sha256=yyGEBYqMXmNs_F2dEtj-PX8HE040vqh-YQppsvdxPw4,2025
111
113
  langfun/core/modalities/image.py,sha256=ovcX8NLBNv8WzxAdhQ-u4VQfHVBkWijRj_oiNwhE9lk,1768
112
114
  langfun/core/modalities/image_test.py,sha256=XMgtJXY75R5eo0CZ222D1QUy57_hESnttmCGWwDLt7k,3824
113
- langfun/core/modalities/mime.py,sha256=jKE1eDaP46isD-IjWgfzhxnTcmQJ-b4wCoq6tury3J8,7576
114
- langfun/core/modalities/mime_test.py,sha256=lC99gsaTUwVkxQat9hkR3CV-1GI-QPMgwaIdf9EqnoM,4471
115
+ langfun/core/modalities/mime.py,sha256=xZpnENHqwIUBLbT3s3izJvAPnw3XTtXe2v1y4mz9UkI,7856
116
+ langfun/core/modalities/mime_test.py,sha256=Lg21nKFi--a884gnI7tFS4cHnwByEEhWg4Ugsr-UCbw,5277
115
117
  langfun/core/modalities/ms_office.py,sha256=0PnM6W9SovVfJNd4XCpUfOcGBuvj4hlA1zqPjdsJNFM,3725
116
118
  langfun/core/modalities/ms_office_test.py,sha256=rrDBx51ELAqRaUX6Y6tgg0k3tEFHOlRMfUpeULD7mlo,87868
117
119
  langfun/core/modalities/pdf.py,sha256=mfaeCbUA4JslFVTARiJh8hW7imvL4tLVw9gUhO5bAZA,727
@@ -125,13 +127,13 @@ langfun/core/structured/description.py,sha256=6BztYOiucPkF4CrTQtPLPJo1gN2dwnKmaJ
125
127
  langfun/core/structured/description_test.py,sha256=UxaXnKKP7TnyPDPUyf3U-zPE0TvLlIP6DGr8thjcePw,7365
126
128
  langfun/core/structured/function_generation.py,sha256=g7AOR_e8HxFU6n6Df750aGkgMgV1KExLZMAz0yd5Agg,8555
127
129
  langfun/core/structured/function_generation_test.py,sha256=LaXYDXf9GlqUrR6v_gtmK_H4kxzonmU7SYbn7XXMgjU,12128
128
- langfun/core/structured/mapping.py,sha256=vLKH79UT-j0qkQdvqlQBO7SkXXuM-yr2Idm8_HH8qwM,13649
129
- langfun/core/structured/mapping_test.py,sha256=bHm2ZCXBITq_G8Lvw_olFHeUUc4s_lGXZm9v9JhoPB4,9630
130
+ langfun/core/structured/mapping.py,sha256=of-EeBq0RgmkiUaSk2rVEDVCzgn_wXU8tRke7NCcC6E,13649
131
+ langfun/core/structured/mapping_test.py,sha256=OntYvfDitAf0tAnzQty3YS90vyEn6FY1Mi93r_ViEk8,9594
130
132
  langfun/core/structured/parsing.py,sha256=MGvI7ypXlwfzr5XB8_TFU9Ei0_5reYqkWkv64eAy0EA,12015
131
133
  langfun/core/structured/parsing_test.py,sha256=kNPrhpdPY3iWhUld0TFYU-Zgn44wC0d6YuQ9XdVbQ8o,22346
132
134
  langfun/core/structured/querying.py,sha256=nqvsfMS_KLv5EvO0_VAGEHwY4pHy4S0CvJmeV0HBXlM,23066
133
135
  langfun/core/structured/querying_test.py,sha256=YlC4s9LVChfhGZzaXGW1UYlcBnAjNOunu4SLl5_p7PQ,32054
134
- langfun/core/structured/schema.py,sha256=0VUPSfX1JEQ0xu8WvEymCKK_WSGwBNA-rQD2hATErmU,27912
136
+ langfun/core/structured/schema.py,sha256=_iqhHEGDQsHk0AsybWnK44sOspTWkKJjci781PWD7x0,27988
135
137
  langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
136
138
  langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
137
139
  langfun/core/structured/schema_test.py,sha256=RjYhwTgktQgyqAjzLvo967nTiIK9KWgP-aNGg4e7ihE,25258
@@ -148,8 +150,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
148
150
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
149
151
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
150
152
  langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
151
- langfun-0.1.2.dev202501060804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
152
- langfun-0.1.2.dev202501060804.dist-info/METADATA,sha256=3MbJlnp-TmGrXXb9jhRPLd7g86sm9b2zDXLWIWMkkZA,7941
153
- langfun-0.1.2.dev202501060804.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
154
- langfun-0.1.2.dev202501060804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
155
- langfun-0.1.2.dev202501060804.dist-info/RECORD,,
153
+ langfun-0.1.2.dev202501100804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
154
+ langfun-0.1.2.dev202501100804.dist-info/METADATA,sha256=EZ_6YTbKX4JLhwEtNsbhnP2jliYGS3adCNg4oFSYin4,8172
155
+ langfun-0.1.2.dev202501100804.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
156
+ langfun-0.1.2.dev202501100804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
157
+ langfun-0.1.2.dev202501100804.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.7.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,168 +0,0 @@
1
- # Copyright 2023 The Langfun Authors
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """Utility library for LM input/output formatting."""
15
-
16
- import io
17
- import re
18
- from typing import Any
19
-
20
- try:
21
- import termcolor # pylint: disable=g-import-not-at-top
22
- except ImportError:
23
- termcolor = None
24
-
25
-
26
- # Regular expression for ANSI color characters.
27
- _ANSI_COLOR_REGEX = re.compile(r'\x1b\[[0-9;]*m')
28
-
29
-
30
- def decolored(text: str) -> str:
31
- """Return the de-colored string that may contains ANSI color characters."""
32
- return re.sub(_ANSI_COLOR_REGEX, '', text)
33
-
34
-
35
- def colored(
36
- text: str,
37
- color: str | None = None,
38
- background: str | None = None,
39
- styles: list[str] | None = None
40
- ) -> str:
41
- """Returns the colored text with ANSI color characters.
42
-
43
- Args:
44
- text: A string that may or may not already has ANSI color characters.
45
- color: A string for text colors. Applicable values are:
46
- 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'.
47
- background: A string for background colors. Applicable values are:
48
- 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'.
49
- styles: A list of strings for applying styles on the text.
50
- Applicable values are:
51
- 'bold', 'dark', 'underline', 'blink', 'reverse', 'concealed'.
52
-
53
- Returns:
54
- A string with ANSI color characters embracing the entire text.
55
- """
56
- if not termcolor:
57
- return text
58
- return termcolor.colored(
59
- text,
60
- color=color,
61
- on_color=('on_' + background) if background else None,
62
- attrs=styles)
63
-
64
-
65
- def colored_template(
66
- text: str,
67
- expression_color: str | None = 'white',
68
- expression_background: str | None = 'blue',
69
- expression_styles: list[str] | None = None,
70
- statement_color: str | None = 'red',
71
- statement_background: str | None = None,
72
- statement_styles: list[str] | None = None,
73
- comment_color: str | None = 'green',
74
- comment_background: str | None = None,
75
- comment_styles: list[str] | None = None,
76
- ) -> str:
77
- """Returns colored (maybe) Jinja2 template string."""
78
- text = color_text_blocks(
79
- text, '{{', '}}',
80
- color=expression_color,
81
- background=expression_background,
82
- styles=expression_styles)
83
-
84
- text = color_text_blocks(
85
- text, '{%', '%}',
86
- color=statement_color,
87
- background=statement_background,
88
- styles=statement_styles)
89
-
90
- text = color_text_blocks(
91
- text, '{#', '#}',
92
- color=comment_color,
93
- background=comment_background,
94
- styles=comment_styles)
95
-
96
- return text
97
-
98
-
99
- def color_text_blocks(
100
- text: str,
101
- block_start: str,
102
- block_end: str,
103
- color: str | None = None,
104
- background: str | None = None,
105
- styles: list[str] | None = None
106
- ) -> str:
107
- """Apply colors to text blocks.
108
-
109
- Args:
110
- text: A string that may or may not already has ANSI color characters.
111
- block_start: A string that signals the start of a block. E.g. '{{'
112
- block_end: A string that signals the end of a block. E.g. '}}'.
113
- color: A string for text colors. Applicable values are:
114
- 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'.
115
- background: A string for background colors. Applicable values are:
116
- 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'.
117
- styles: A list of strings for applying styles on the text.
118
- Applicable values are:
119
- 'bold', 'dark', 'underline', 'blink', 'reverse', 'concealed'.
120
-
121
- Returns:
122
- A string with ANSI color characters embracing the matched text blocks.
123
- """
124
- if not color and not background and not styles:
125
- return text
126
-
127
- string_buffer = io.StringIO()
128
- start_index = 0
129
- end_index = 0
130
- previous_color = None
131
-
132
- def write_nonblock_text(text: str, previous_color: str | None):
133
- if previous_color:
134
- string_buffer.write(previous_color)
135
- string_buffer.write(text)
136
-
137
- while start_index < len(text):
138
- start_index = text.find(block_start, end_index)
139
- if start_index == -1:
140
- write_nonblock_text(text[end_index:], previous_color)
141
- break
142
-
143
- # Deal with text since last block.
144
- since_last_block = text[end_index:start_index]
145
- write_nonblock_text(since_last_block, previous_color)
146
- colors = re.findall(_ANSI_COLOR_REGEX, since_last_block)
147
- if colors:
148
- previous_color = colors[-1]
149
-
150
- # Match block.
151
- end_index = text.find(block_end, start_index + len(block_start))
152
- if end_index == -1:
153
- write_nonblock_text(text[start_index:], previous_color)
154
- break
155
- end_index += len(block_end)
156
-
157
- # Write block text.
158
- block = text[start_index:end_index]
159
- colored_block = colored(
160
- block, color=color, background=background, styles=styles)
161
- string_buffer.write(colored_block)
162
- return string_buffer.getvalue()
163
-
164
-
165
- def colored_print(value: Any):
166
- """Prints text with color."""
167
- print(colored_template(str(value)))
168
-
@@ -1,65 +0,0 @@
1
- # Copyright 2023 The Langfun Authors
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """Tests for text formatting."""
15
-
16
- import inspect
17
- import unittest
18
- from langfun.core import text_formatting
19
-
20
-
21
- class TextFormattingTest(unittest.TestCase):
22
-
23
- def test_colored_template(self):
24
- original_text = inspect.cleandoc("""
25
- Hi {{ foo }}
26
- {# print x if x is present #}
27
- {% if x %}
28
- {{ x }}
29
- {% endif %}
30
- """)
31
-
32
- colored_text = text_formatting.colored_template(
33
- text_formatting.colored(original_text, color='blue')
34
- )
35
- self.assertEqual(
36
- colored_text,
37
- '\x1b[34mHi \x1b[44m\x1b[37m{{ foo }}\x1b[0m\x1b[34m\n'
38
- '\x1b[32m{# print x if x is present #}\x1b[0m\x1b[34m\n'
39
- '\x1b[31m{% if x %}\x1b[0m\x1b[34m\n'
40
- '\x1b[44m\x1b[37m{{ x }}\x1b[0m\x1b[34m\n'
41
- '\x1b[31m{% endif %}\x1b[0m\x1b[34m\x1b[0m'
42
- )
43
- self.assertEqual(text_formatting.decolored(colored_text), original_text)
44
-
45
- def test_colored_without_termcolor(self):
46
- termcolor = text_formatting.termcolor
47
- text_formatting.termcolor = None
48
- original_text = inspect.cleandoc("""
49
- Hi {{ foo }}
50
- {# print x if x is present #}
51
- {% if x %}
52
- {{ x }}
53
- {% endif %}
54
- """)
55
-
56
- colored_text = text_formatting.colored_template(
57
- text_formatting.colored(original_text, color='blue')
58
- )
59
- self.assertEqual(colored_text, original_text)
60
- self.assertEqual(text_formatting.decolored(colored_text), original_text)
61
- text_formatting.termcolor = termcolor
62
-
63
-
64
- if __name__ == '__main__':
65
- unittest.main()