langfun 0.0.2.dev20240429__py3-none-any.whl → 0.1.2.dev202501140804__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 (144) hide show
  1. langfun/__init__.py +20 -2
  2. langfun/core/__init__.py +16 -5
  3. langfun/core/agentic/__init__.py +30 -0
  4. langfun/core/agentic/action.py +854 -0
  5. langfun/core/agentic/action_eval.py +150 -0
  6. langfun/core/agentic/action_eval_test.py +109 -0
  7. langfun/core/agentic/action_test.py +136 -0
  8. langfun/core/coding/python/__init__.py +5 -11
  9. langfun/core/coding/python/correction.py +37 -21
  10. langfun/core/coding/python/correction_test.py +29 -3
  11. langfun/core/coding/python/execution.py +40 -216
  12. langfun/core/coding/python/execution_test.py +29 -89
  13. langfun/core/coding/python/generation.py +21 -11
  14. langfun/core/coding/python/generation_test.py +2 -2
  15. langfun/core/coding/python/parsing.py +108 -193
  16. langfun/core/coding/python/parsing_test.py +2 -105
  17. langfun/core/component.py +63 -2
  18. langfun/core/component_test.py +53 -0
  19. langfun/core/concurrent.py +414 -117
  20. langfun/core/concurrent_test.py +111 -24
  21. langfun/core/console.py +18 -5
  22. langfun/core/console_test.py +17 -0
  23. langfun/core/eval/__init__.py +16 -1
  24. langfun/core/eval/base.py +622 -174
  25. langfun/core/eval/base_test.py +200 -54
  26. langfun/core/eval/matching.py +63 -76
  27. langfun/core/eval/matching_test.py +17 -8
  28. langfun/core/eval/patching.py +130 -0
  29. langfun/core/eval/patching_test.py +170 -0
  30. langfun/core/eval/scoring.py +26 -26
  31. langfun/core/eval/scoring_test.py +19 -2
  32. langfun/core/eval/v2/__init__.py +42 -0
  33. langfun/core/eval/v2/checkpointing.py +380 -0
  34. langfun/core/eval/v2/checkpointing_test.py +228 -0
  35. langfun/core/eval/v2/eval_test_helper.py +136 -0
  36. langfun/core/eval/v2/evaluation.py +725 -0
  37. langfun/core/eval/v2/evaluation_test.py +180 -0
  38. langfun/core/eval/v2/example.py +305 -0
  39. langfun/core/eval/v2/example_test.py +128 -0
  40. langfun/core/eval/v2/experiment.py +1048 -0
  41. langfun/core/eval/v2/experiment_test.py +433 -0
  42. langfun/core/eval/v2/metric_values.py +156 -0
  43. langfun/core/eval/v2/metric_values_test.py +80 -0
  44. langfun/core/eval/v2/metrics.py +357 -0
  45. langfun/core/eval/v2/metrics_test.py +203 -0
  46. langfun/core/eval/v2/progress.py +348 -0
  47. langfun/core/eval/v2/progress_test.py +82 -0
  48. langfun/core/eval/v2/progress_tracking.py +210 -0
  49. langfun/core/eval/v2/progress_tracking_test.py +66 -0
  50. langfun/core/eval/v2/reporting.py +270 -0
  51. langfun/core/eval/v2/reporting_test.py +158 -0
  52. langfun/core/eval/v2/runners.py +488 -0
  53. langfun/core/eval/v2/runners_test.py +334 -0
  54. langfun/core/langfunc.py +4 -17
  55. langfun/core/langfunc_test.py +22 -6
  56. langfun/core/language_model.py +577 -39
  57. langfun/core/language_model_test.py +470 -56
  58. langfun/core/llms/__init__.py +87 -16
  59. langfun/core/llms/anthropic.py +312 -87
  60. langfun/core/llms/anthropic_test.py +71 -3
  61. langfun/core/llms/cache/base.py +21 -2
  62. langfun/core/llms/cache/in_memory.py +13 -0
  63. langfun/core/llms/cache/in_memory_test.py +53 -2
  64. langfun/core/llms/compositional.py +101 -0
  65. langfun/core/llms/compositional_test.py +73 -0
  66. langfun/core/llms/deepseek.py +117 -0
  67. langfun/core/llms/deepseek_test.py +61 -0
  68. langfun/core/llms/fake.py +11 -7
  69. langfun/core/llms/fake_test.py +14 -0
  70. langfun/core/llms/gemini.py +507 -0
  71. langfun/core/llms/gemini_test.py +195 -0
  72. langfun/core/llms/google_genai.py +62 -218
  73. langfun/core/llms/google_genai_test.py +9 -202
  74. langfun/core/llms/groq.py +160 -144
  75. langfun/core/llms/groq_test.py +31 -137
  76. langfun/core/llms/llama_cpp.py +15 -42
  77. langfun/core/llms/llama_cpp_test.py +4 -30
  78. langfun/core/llms/openai.py +395 -203
  79. langfun/core/llms/openai_compatible.py +179 -0
  80. langfun/core/llms/openai_compatible_test.py +495 -0
  81. langfun/core/llms/openai_test.py +30 -395
  82. langfun/core/llms/rest.py +113 -0
  83. langfun/core/llms/rest_test.py +111 -0
  84. langfun/core/llms/vertexai.py +192 -0
  85. langfun/core/llms/vertexai_test.py +52 -0
  86. langfun/core/logging.py +284 -0
  87. langfun/core/logging_test.py +125 -0
  88. langfun/core/message.py +319 -9
  89. langfun/core/message_test.py +190 -13
  90. langfun/core/modalities/__init__.py +6 -2
  91. langfun/core/modalities/audio.py +30 -0
  92. langfun/core/modalities/audio_test.py +63 -0
  93. langfun/core/modalities/image.py +39 -20
  94. langfun/core/modalities/image_test.py +52 -9
  95. langfun/core/modalities/mime.py +206 -29
  96. langfun/core/modalities/mime_test.py +90 -9
  97. langfun/core/modalities/ms_office.py +117 -0
  98. langfun/core/modalities/ms_office_test.py +389 -0
  99. langfun/core/modalities/pdf.py +22 -0
  100. langfun/core/modalities/pdf_test.py +57 -0
  101. langfun/core/modalities/video.py +9 -26
  102. langfun/core/modalities/video_test.py +3 -3
  103. langfun/core/modality.py +26 -3
  104. langfun/core/modality_test.py +2 -2
  105. langfun/core/sampling.py +11 -11
  106. langfun/core/structured/__init__.py +12 -16
  107. langfun/core/structured/completion.py +32 -5
  108. langfun/core/structured/completion_test.py +7 -6
  109. langfun/core/structured/description.py +2 -2
  110. langfun/core/structured/description_test.py +3 -3
  111. langfun/core/structured/function_generation.py +60 -27
  112. langfun/core/structured/function_generation_test.py +72 -2
  113. langfun/core/structured/mapping.py +97 -47
  114. langfun/core/structured/mapping_test.py +90 -2
  115. langfun/core/structured/parsing.py +33 -21
  116. langfun/core/structured/parsing_test.py +53 -9
  117. langfun/core/structured/querying.py +746 -0
  118. langfun/core/structured/{prompting_test.py → querying_test.py} +469 -51
  119. langfun/core/structured/schema.py +204 -97
  120. langfun/core/structured/schema_generation.py +1 -1
  121. langfun/core/structured/schema_test.py +130 -29
  122. langfun/core/structured/scoring.py +125 -19
  123. langfun/core/structured/scoring_test.py +30 -0
  124. langfun/core/structured/tokenization.py +64 -0
  125. langfun/core/structured/tokenization_test.py +48 -0
  126. langfun/core/template.py +115 -1
  127. langfun/core/template_test.py +71 -1
  128. langfun/core/templates/conversation.py +9 -0
  129. langfun/core/templates/conversation_test.py +4 -3
  130. langfun/core/templates/selfplay_test.py +10 -2
  131. langfun-0.1.2.dev202501140804.dist-info/METADATA +225 -0
  132. langfun-0.1.2.dev202501140804.dist-info/RECORD +153 -0
  133. {langfun-0.0.2.dev20240429.dist-info → langfun-0.1.2.dev202501140804.dist-info}/WHEEL +1 -1
  134. langfun/core/coding/python/errors.py +0 -108
  135. langfun/core/coding/python/errors_test.py +0 -99
  136. langfun/core/coding/python/permissions.py +0 -90
  137. langfun/core/coding/python/permissions_test.py +0 -86
  138. langfun/core/structured/prompting.py +0 -238
  139. langfun/core/text_formatting.py +0 -162
  140. langfun/core/text_formatting_test.py +0 -47
  141. langfun-0.0.2.dev20240429.dist-info/METADATA +0 -100
  142. langfun-0.0.2.dev20240429.dist-info/RECORD +0 -108
  143. {langfun-0.0.2.dev20240429.dist-info → langfun-0.1.2.dev202501140804.dist-info}/LICENSE +0 -0
  144. {langfun-0.0.2.dev20240429.dist-info → langfun-0.1.2.dev202501140804.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,153 @@
1
+ langfun/__init__.py,sha256=fhfPXpHN7GoGqixpFfqhQkYxFs_siP_LhbjZhd3lhio,2497
2
+ langfun/core/__init__.py,sha256=oo81OUA4Xy2q7icxcxAMicVzbla5gMDf9Nzw_iIAkis,4627
3
+ langfun/core/component.py,sha256=HVrEoTL1Y01iqOHC3FYdbAOnffqfHHtGJXoK1vkdEwo,11583
4
+ langfun/core/component_test.py,sha256=sG-T2wpvBfHqWGZE7sc4NayJj2aj5QFBzSwFiwrGEIc,10376
5
+ langfun/core/concurrent.py,sha256=4CqOlH9YrtrK-Jijp09hLX7AYxRYL8slpy-tL2aqnIM,33121
6
+ langfun/core/concurrent_test.py,sha256=0ucEYxPgTErOOK1TIN-TSqZphHS1Vl1VssyQP49cpOI,17997
7
+ langfun/core/console.py,sha256=bGwuJZRs_9NNKY1KmJjIZLeoQ_fL0BikAJPLDVdp1hw,2558
8
+ langfun/core/console_test.py,sha256=pBOcuNMJdVELywvroptfcRtJMsegMm3wSlHAL2TdxVk,1679
9
+ langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,11140
10
+ langfun/core/langfunc_test.py,sha256=fKIAqcSNI_7M6nwoZW77HEam8Oa6vcWhsCNgVJanzb4,8822
11
+ langfun/core/language_model.py,sha256=Hfs-SIxiO2rK7BvPmnOuYTrT4jbmFiV31NMmI-mkPzY,36635
12
+ langfun/core/language_model_test.py,sha256=jic5w8w9Mie43e6zwjXDwLV-8Cqc1HxHP0GKkXzeL8I,33666
13
+ langfun/core/logging.py,sha256=W3mLEMXdo210Q5OX3a1ZTc4nU-xMy73-IfNKnsA-RFo,8051
14
+ langfun/core/logging_test.py,sha256=N7-YvSXC8zvnr2SNwWHOykn1CFmqvIuTLDgn41Ku9JU,6642
15
+ langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
16
+ langfun/core/message.py,sha256=16oiMpg9O9VKrgpfrvJrfvga3n3FzUuD_zdWb9nvSWA,25686
17
+ langfun/core/message_test.py,sha256=AAKOZitp-Pu_w2x98zV6hQhll2ZTmWdtW0vmT3MyOjI,36165
18
+ langfun/core/modality.py,sha256=K8pUGuMpfWcOtVcXC_OqVjro1-RhHF6ddQni61DuYzM,4166
19
+ langfun/core/modality_test.py,sha256=0WL_yd3B4K-FviWdSpDnOwj0f9TQI0v9t6X0vWvvJbo,2415
20
+ langfun/core/natural_language.py,sha256=3ynSnaYQnjE60LIPK5fyMgdIjubnPYZwzGq4rWPeloE,1177
21
+ langfun/core/natural_language_test.py,sha256=LHGU_1ytbkGuSZQFIFP7vP3dBlcY4-A12fT6dbjUA0E,1424
22
+ langfun/core/sampling.py,sha256=SCnS5PFJWNVxSKvSkSCNRUmruvScun8UcNN4gafuXcw,5866
23
+ langfun/core/sampling_test.py,sha256=U7PANpMsl9E_pa4_Y4FzesSjcwg-u-LKHGCWSgv-8FY,3663
24
+ langfun/core/subscription.py,sha256=euawEuSZP-BHydaT-AQpfYFL0m5pWPGcW0upFhrojqc,10930
25
+ langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIcArBo,8717
26
+ langfun/core/template.py,sha256=jNhYSrbLIn9kZOa03w5QZbyjgfnzJzE_ZrrMvvWY4t4,24929
27
+ langfun/core/template_test.py,sha256=g7x4mgNIAXEEj-4W1D5whGfl5YikLEQoylKPzaeDomk,17069
28
+ langfun/core/agentic/__init__.py,sha256=ndoDX0sAYsa3eVdXuu6nB-a-BH5TaK3urW6zAaFiyVs,1110
29
+ langfun/core/agentic/action.py,sha256=yW5-2NRHIrQmmQEYmL83aIdSwaRfUez9mqCbME_aBWQ,25391
30
+ langfun/core/agentic/action_eval.py,sha256=ZtjTh34S7XPIUqandQ0YwAtzw-S7ofuZ7rRXnRbUMdQ,4424
31
+ langfun/core/agentic/action_eval_test.py,sha256=tRUkWmOE9p0rpNOq19xAY2oDEnYsEEykjg6sUpAwJk0,2832
32
+ langfun/core/agentic/action_test.py,sha256=Gu7P5XQvzqbKawn2jjyTpWaARzzhzO04KkC1TuBnUnw,4612
33
+ langfun/core/coding/__init__.py,sha256=5utju_fwEsImaiftx4oXKl9FAM8p281k8-Esdh_-m1w,835
34
+ langfun/core/coding/python/__init__.py,sha256=K6jb2le6Hq-aaKqAF4pGW5JRwSyO-RnUTMIxxaVcsNA,1540
35
+ langfun/core/coding/python/correction.py,sha256=7zBedlhQKMPA4cfchUMxAOFl6Zl5RqCyllRHGWys40s,7092
36
+ langfun/core/coding/python/correction_test.py,sha256=sie88lAbsV15bvkRcYC88pgToybZYXI32Xmg_ym5V1A,4175
37
+ langfun/core/coding/python/execution.py,sha256=tsXnJ-11RqNDro0C-6LwbHkqPuNVJ_cLxAq8-C5Wz20,4442
38
+ langfun/core/coding/python/execution_test.py,sha256=NynCGNP0gZ08fqmmQIJjJu6HmhkNOSkgWUXUCNQ0_yg,5990
39
+ langfun/core/coding/python/generation.py,sha256=sA6t97qBflO3WtuL9axknEVQPgqXHeqamTQitc_hL4k,8446
40
+ langfun/core/coding/python/generation_test.py,sha256=dcF5ef1UApzRfTpvICiChpynkzZ1mDsE0DvH0iMpTvg,2743
41
+ langfun/core/coding/python/parsing.py,sha256=jvGDIwoaY3mdGXeFhjP27w0ukO0TtdCC7G4ODVNp8S4,4554
42
+ langfun/core/coding/python/parsing_test.py,sha256=PIexYpSEhgNaSd4T6QYWzWHzm3sL4VhQJ4dhdvJAQk8,5005
43
+ langfun/core/eval/__init__.py,sha256=OEXr1ZRuvLuhJJfuQ1ZWQ-SvYzjyrtiAAEogYaB7E6o,1933
44
+ langfun/core/eval/base.py,sha256=XXerMVkK4wREo7K1_aCyay6vDjw3mfs389XThAdzv50,75768
45
+ langfun/core/eval/base_test.py,sha256=-LsIV9DXlDal0EnOlaWpibJvfef0NbxtZAm0OH_abAE,27189
46
+ langfun/core/eval/matching.py,sha256=AVKkGoc-BaHEzgSBamaAk3194TgqckDe_dinpS6LrXI,9323
47
+ langfun/core/eval/matching_test.py,sha256=QCoYEuf4b_1bkHqUCuRzKMbXHrV3AB2FCOBivo1stC4,5249
48
+ langfun/core/eval/patching.py,sha256=R0s2eAd1m97exQt06dmUL0V_MBG0W2Hxg7fhNB7cXW0,3866
49
+ langfun/core/eval/patching_test.py,sha256=8kCd54Egjju22FMgtJuxEsrXkW8ifs-UUBHtrCG1L6w,4775
50
+ langfun/core/eval/scoring.py,sha256=_DvnlgI1SdRVaOojao_AkV3pnenfCPOqyhvlg-Sw-5M,6322
51
+ langfun/core/eval/scoring_test.py,sha256=O8olHbrUEg60gMxwOkWzKBJZpZoUlmVnBANX5Se2SXM,4546
52
+ langfun/core/eval/v2/__init__.py,sha256=qoa6zKdFXOFyCX6vay6OdgPf1eUhYGoHYAxe35qECGk,1628
53
+ langfun/core/eval/v2/checkpointing.py,sha256=u-MrnwQbm0T-BDcn9pPXs_FeKPzMYm1-pVos0DiTqgM,11769
54
+ langfun/core/eval/v2/checkpointing_test.py,sha256=R-R8SFzworuYnMmGGcvE9f4oiYkb8HMoZ0m4euF3pus,8466
55
+ langfun/core/eval/v2/eval_test_helper.py,sha256=A9w0FbRKieB3yym8x34kY24FfptHrp7m6_z3i8HXSFI,3922
56
+ langfun/core/eval/v2/evaluation.py,sha256=kARf0pG6SrpN__IMeFsw8DV_5mT_tl52pJrr6wIZdsw,22482
57
+ langfun/core/eval/v2/evaluation_test.py,sha256=0l0DqJTF8PZGA2Q1OlaF4YIax4ZhSk0ewOCvuVW1XAk,6658
58
+ langfun/core/eval/v2/example.py,sha256=4-LNr8Ke-fhaF6gyeXX4JMyw0s8YkVTC63pXZ-CXKrE,10144
59
+ langfun/core/eval/v2/example_test.py,sha256=1DNm6EuyZOq827DKvf3oTRVFkMNM_qTnLUpvOjpgz5I,3419
60
+ langfun/core/eval/v2/experiment.py,sha256=qYWx22KMfoUa4ieSq1bt7NE8L9dgoiJpuNOQGT1IBQw,32723
61
+ langfun/core/eval/v2/experiment_test.py,sha256=CqpDsDai2DiIU-SzpVmqFzM_ZxxkVYKd0Gr1Uvcvkuw,13546
62
+ langfun/core/eval/v2/metric_values.py,sha256=_B905bC-jxrYPLSEcP2M8MaHZOVMz_bVrUw8YC4arCE,4660
63
+ langfun/core/eval/v2/metric_values_test.py,sha256=ab2oF_HsIwrSy459108ggyjgefHSPn8UVILR4dRwx14,2634
64
+ langfun/core/eval/v2/metrics.py,sha256=bl8i6u-ZHRBz4hAc3LzsZ2Dc7ZRQcuTYeUhhH-GxfF0,10628
65
+ langfun/core/eval/v2/metrics_test.py,sha256=p4FzLJsE8XAzAQuyP9hfEf9YeKWZ__PO_ue8a9P0-cc,6082
66
+ langfun/core/eval/v2/progress.py,sha256=azZgssQgNdv3IgjKEaQBuGI5ucFDNbdi02P4z_nQ8GE,10292
67
+ langfun/core/eval/v2/progress_test.py,sha256=YU7VHzmy5knPZwj9vpBN3rQQH2tukj9eKHkuBCI62h8,2540
68
+ langfun/core/eval/v2/progress_tracking.py,sha256=l9fEkz4oP5McpZzf72Ua7PYm3lAWtRru7gRWNf8H0ms,6083
69
+ langfun/core/eval/v2/progress_tracking_test.py,sha256=fouMVJkFJqHjbhQJngGLGCmA9x3n0dU4USI2dY163mg,2291
70
+ langfun/core/eval/v2/reporting.py,sha256=QOp5jX761Esvi5w_UIRLDqPY_XRO6ru02-DOrdqVK_4,8392
71
+ langfun/core/eval/v2/reporting_test.py,sha256=UmYSAQvD3AIXsSyWQ-WD2uLtEISYpmBeoKY5u5Qwc8E,5696
72
+ langfun/core/eval/v2/runners.py,sha256=DKEmSlGXjOXKWFdBhTpLy7tMsBHZHd1Brl3hWIngsSQ,15931
73
+ langfun/core/eval/v2/runners_test.py,sha256=A37fKK2MvAVTiShsg_laluJzJ9AuAQn52k7HPbfD0Ks,11666
74
+ langfun/core/llms/__init__.py,sha256=Ntr0kvHc17VEZ5EV9fCoYY1kzRvQxCoZrtDRYNiMWCs,6742
75
+ langfun/core/llms/anthropic.py,sha256=a5MmnFsBA0CbfvwzXT1v_0fqLRMrhUNdh1tx6469PQ4,14357
76
+ langfun/core/llms/anthropic_test.py,sha256=-2U4kc_pgBM7wqxu8RuxzyHPGww1EAWqKUvN4PW8Btw,8058
77
+ langfun/core/llms/compositional.py,sha256=csW_FLlgL-tpeyCOTVvfUQkMa_zCN5Y2I-YbSNuK27U,2872
78
+ langfun/core/llms/compositional_test.py,sha256=4eTnOer-DncRKGaIJW2ZQQMLnt5r2R0UIx_DYOvGAQo,2027
79
+ langfun/core/llms/deepseek.py,sha256=Y7DlLUWrukbPVyBMesppd-m75Q-PxD0b3KnMKaoY_8I,3744
80
+ langfun/core/llms/deepseek_test.py,sha256=dS72i52bwMpCN4dJDvpJI59AnNChpwxS5eYYFrhGh90,1843
81
+ langfun/core/llms/fake.py,sha256=gCHBYBLvBCsC78HI1hpoqXCS-p1FMTgY1P1qh_sGBPk,3070
82
+ langfun/core/llms/fake_test.py,sha256=2h13qkwEz_JR0mtUDPxdAhQo7MueXaFSwsD2DIRDW9g,7653
83
+ langfun/core/llms/gemini.py,sha256=tfM4vrt0WnvnrxRhWXZWh7Gp8dYYfMnSbi9uOstkSak,17399
84
+ langfun/core/llms/gemini_test.py,sha256=2ERhYWCJwnfDTQbCaZHFuB1TdWJFrOBS7yyCBInIdQk,6129
85
+ langfun/core/llms/google_genai.py,sha256=85Vmx5QmsziON03PRsFQINSu5NF6pAAuFFhUdDteWGc,3662
86
+ langfun/core/llms/google_genai_test.py,sha256=JZf_cbQ4GGGpwiQCLjFJn7V4jxBBqgZhIx91AzbGKVo,1250
87
+ langfun/core/llms/groq.py,sha256=oGxyyCi5TtMVu2POdO8pXS7pK4Es56FtqjghZIGYopc,7579
88
+ langfun/core/llms/groq_test.py,sha256=9aOD3nO4dEoH57B-5iOr5DQjG0vyv1jzFtAe7HfoiNg,1963
89
+ langfun/core/llms/llama_cpp.py,sha256=Z7P3gc4xeIjc2bX0Ey1y5EUYJVMnMa2Q67PZ9iye9sE,1409
90
+ langfun/core/llms/llama_cpp_test.py,sha256=wfTO7nmUwL65U2kK9P9fcMt92JjNDuVia4G1E7znf_4,1086
91
+ langfun/core/llms/openai.py,sha256=CHUg8c0FE30LZkhvj0Kc8w0oqckbZhrp45GA94HWPs8,16614
92
+ langfun/core/llms/openai_compatible.py,sha256=MF9JCc0uTPkIK95uvQTMIBXk4z_xKQMZqQHFaVmXwcA,5898
93
+ langfun/core/llms/openai_compatible_test.py,sha256=0uFYhCiuHo2Wrlgj16-GRG6rW8P6EaHCUguL3jS0QJ8,16708
94
+ langfun/core/llms/openai_test.py,sha256=m85YjGCvWvV5ZYagjC0FqI0FcqyCEVCbUUs8Wm3iUrc,2475
95
+ langfun/core/llms/rest.py,sha256=sWbYUV8S3SuOg9giq7xwD-xDRfaF7NP_ig7bI52-Rj4,3442
96
+ langfun/core/llms/rest_test.py,sha256=zWGiI08f9gXsoQPJS9TlX1zD2uQLrJUB-1VpAJXRHfs,3475
97
+ langfun/core/llms/vertexai.py,sha256=MuwLPTJ6-9x2uRDCSM1_biPK6M76FFlL1ezf5OmobDA,5504
98
+ langfun/core/llms/vertexai_test.py,sha256=iXjmQs7TNiwcueoaRGpdp4KnASkDJaTP__Z9QroN8zQ,1787
99
+ langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
100
+ langfun/core/llms/cache/base.py,sha256=rt3zwmyw0y9jsSGW-ZbV1vAfLxQ7_3AVk0l2EySlse4,3918
101
+ langfun/core/llms/cache/in_memory.py,sha256=i58oiQL28RDsq37dwqgVpC2mBETJjIEFS20yHiV5MKU,5185
102
+ langfun/core/llms/cache/in_memory_test.py,sha256=V2UPeu5co5vUwSkjekCH1B1iLm9qQKPaacvP6VW3GTg,10388
103
+ langfun/core/memories/__init__.py,sha256=HpghfZ-w1NQqzJXBx8Lz0daRhB2rcy2r9Xm491SBhC4,773
104
+ langfun/core/memories/conversation_history.py,sha256=c9amD8hCxGFiZuVAzkP0dOMWSp8L90uvwkOejjuBqO0,1835
105
+ langfun/core/memories/conversation_history_test.py,sha256=AaW8aNoFjxNusanwJDV0r3384Mg0eAweGmPx5DIkM0Y,2052
106
+ langfun/core/modalities/__init__.py,sha256=F8P72IwFiTpEseTR2tYEJyQMlDW7fd9csvGJquLKJNg,1269
107
+ langfun/core/modalities/audio.py,sha256=qCrVCX690SG0ps-ZfOtNWvHn_CmdJsmxF7GySScWUqY,964
108
+ langfun/core/modalities/audio_test.py,sha256=yyGEBYqMXmNs_F2dEtj-PX8HE040vqh-YQppsvdxPw4,2025
109
+ langfun/core/modalities/image.py,sha256=ovcX8NLBNv8WzxAdhQ-u4VQfHVBkWijRj_oiNwhE9lk,1768
110
+ langfun/core/modalities/image_test.py,sha256=XMgtJXY75R5eo0CZ222D1QUy57_hESnttmCGWwDLt7k,3824
111
+ langfun/core/modalities/mime.py,sha256=xZpnENHqwIUBLbT3s3izJvAPnw3XTtXe2v1y4mz9UkI,7856
112
+ langfun/core/modalities/mime_test.py,sha256=Lg21nKFi--a884gnI7tFS4cHnwByEEhWg4Ugsr-UCbw,5277
113
+ langfun/core/modalities/ms_office.py,sha256=0PnM6W9SovVfJNd4XCpUfOcGBuvj4hlA1zqPjdsJNFM,3725
114
+ langfun/core/modalities/ms_office_test.py,sha256=rrDBx51ELAqRaUX6Y6tgg0k3tEFHOlRMfUpeULD7mlo,87868
115
+ langfun/core/modalities/pdf.py,sha256=mfaeCbUA4JslFVTARiJh8hW7imvL4tLVw9gUhO5bAZA,727
116
+ langfun/core/modalities/pdf_test.py,sha256=ulZ0FbnlsU0wkrdckJ4ONZPTYRyMPO9Aob1UO6FXygk,1950
117
+ langfun/core/modalities/video.py,sha256=vI9apcHIHGyp90i34Srg7S3G6IBDtDCk8qiXhwRQmkw,967
118
+ langfun/core/modalities/video_test.py,sha256=7OXZoohKMYjt7vrJUdPb553HLyl1oBOKRgzBePFv68Q,2042
119
+ langfun/core/structured/__init__.py,sha256=3Wb4ks14D5E5z1nQ5trXSXiLqFN5E_3HvcEJQAfFRl0,3220
120
+ langfun/core/structured/completion.py,sha256=yW95Yd4wbt964I5wIyPUtIVeeqeZbA6HidLgN0ZpWm0,8110
121
+ langfun/core/structured/completion_test.py,sha256=VtYfI3ciVSSWbi8x3l1WwpWK-Ofn2DMHYEEqm2uTzhw,19314
122
+ langfun/core/structured/description.py,sha256=6BztYOiucPkF4CrTQtPLPJo1gN2dwnKmaJW83GBf4H0,5213
123
+ langfun/core/structured/description_test.py,sha256=UxaXnKKP7TnyPDPUyf3U-zPE0TvLlIP6DGr8thjcePw,7365
124
+ langfun/core/structured/function_generation.py,sha256=g7AOR_e8HxFU6n6Df750aGkgMgV1KExLZMAz0yd5Agg,8555
125
+ langfun/core/structured/function_generation_test.py,sha256=LaXYDXf9GlqUrR6v_gtmK_H4kxzonmU7SYbn7XXMgjU,12128
126
+ langfun/core/structured/mapping.py,sha256=of-EeBq0RgmkiUaSk2rVEDVCzgn_wXU8tRke7NCcC6E,13649
127
+ langfun/core/structured/mapping_test.py,sha256=OntYvfDitAf0tAnzQty3YS90vyEn6FY1Mi93r_ViEk8,9594
128
+ langfun/core/structured/parsing.py,sha256=MGvI7ypXlwfzr5XB8_TFU9Ei0_5reYqkWkv64eAy0EA,12015
129
+ langfun/core/structured/parsing_test.py,sha256=kNPrhpdPY3iWhUld0TFYU-Zgn44wC0d6YuQ9XdVbQ8o,22346
130
+ langfun/core/structured/querying.py,sha256=nqvsfMS_KLv5EvO0_VAGEHwY4pHy4S0CvJmeV0HBXlM,23066
131
+ langfun/core/structured/querying_test.py,sha256=YlC4s9LVChfhGZzaXGW1UYlcBnAjNOunu4SLl5_p7PQ,32054
132
+ langfun/core/structured/schema.py,sha256=_iqhHEGDQsHk0AsybWnK44sOspTWkKJjci781PWD7x0,27988
133
+ langfun/core/structured/schema_generation.py,sha256=3AcuKvv3VOtKY5zMVqODrxfOuDxzoZtGeBxHlOWDOWw,5308
134
+ langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
135
+ langfun/core/structured/schema_test.py,sha256=RjYhwTgktQgyqAjzLvo967nTiIK9KWgP-aNGg4e7ihE,25258
136
+ langfun/core/structured/scoring.py,sha256=Y7Jqs5VVjUQLF_9Z1uIY_dw5zasv2FF52Cz-cxGMsro,5857
137
+ langfun/core/structured/scoring_test.py,sha256=QvlwDAzwuamKL5tCotm1L3Sx0cs3idoNK4aIEhaO4Yk,2272
138
+ langfun/core/structured/tokenization.py,sha256=-b4_693quHeYn2AqndwucuXNmhd5NVXVTU3mmDane98,2189
139
+ langfun/core/structured/tokenization_test.py,sha256=dVW30kGYkX2HNtiRZe1oTmXFP7iIK6PrlKCttZ3QXe4,1311
140
+ langfun/core/templates/__init__.py,sha256=bO0eMsVJbi7sxEB2YlInKRQ2EVP-RyyKUwcD-8msuN4,927
141
+ langfun/core/templates/completion.py,sha256=mUqZHOEV3ag6-A08XghpeEltcrBvCDxXP004eDDfeag,1931
142
+ langfun/core/templates/completion_test.py,sha256=vGnjnM38UHyVDUyaUYtmp20s9KBGOdbPVsX-H-ET11E,1636
143
+ langfun/core/templates/conversation.py,sha256=dTy_fs3g92d3vP09bACGJ_zJ3b8-OzA8vsKgUDoB76o,2866
144
+ langfun/core/templates/conversation_test.py,sha256=HCD5f1sgmSGqL3OGe7hEctjRdcFjcmkz3NV1ArexNYI,3942
145
+ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fikKhwhzwhpKI,1460
146
+ langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
147
+ langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
148
+ langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
149
+ langfun-0.1.2.dev202501140804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
150
+ langfun-0.1.2.dev202501140804.dist-info/METADATA,sha256=x6f3Dt7iwPgwothAHIYVh629F01uM9B5EJr19nmbPLo,8172
151
+ langfun-0.1.2.dev202501140804.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
152
+ langfun-0.1.2.dev202501140804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
153
+ langfun-0.1.2.dev202501140804.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,108 +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
- """Python code errors."""
15
-
16
- import io
17
- import sys
18
- import textwrap
19
- import traceback
20
- import langfun.core as lf
21
-
22
-
23
- class CodeError(RuntimeError):
24
- """Python code error."""
25
-
26
- def __init__(
27
- self,
28
- code: str,
29
- cause: Exception,
30
- ):
31
- self.code = code
32
- self.cause = cause
33
-
34
- # Figure out the starting and ending line numbers of the erratic code.
35
- lineno = None
36
- end_lineno = None
37
- if isinstance(cause, SyntaxError):
38
- lineno = cause.lineno
39
- end_lineno = cause.end_lineno
40
- elif not isinstance(cause, TimeoutError):
41
- tb = sys.exc_info()[2]
42
- frames = traceback.extract_tb(tb, limit=5)
43
- for f in frames:
44
- if not f.filename or f.filename == '<string>':
45
- lineno = f.lineno
46
- end_lineno = lineno
47
- break
48
- self.lineno = lineno
49
- self.end_lineno = end_lineno
50
-
51
- def __str__(self):
52
- return self.format(include_complete_code=True)
53
-
54
- def code_lines(self, start_line: int, end_line: int):
55
- """Returns code lines ."""
56
- return '\n'.join(self.code.split('\n')[start_line:end_line])
57
-
58
- def format(self, include_complete_code: bool = True):
59
- """Formats the code error."""
60
- r = io.StringIO()
61
- error_message = str(self.cause).rstrip()
62
- if 'line' not in error_message and self.lineno is not None:
63
- error_message += f' (<unknown>, line {self.lineno})'
64
- r.write(
65
- lf.colored(
66
- f'{self.cause.__class__.__name__}: {error_message}', 'magenta'))
67
-
68
- if self.lineno is not None:
69
- r.write('\n\n')
70
- r.write(textwrap.indent(
71
- lf.colored(
72
- self.code_lines(self.lineno - 1, self.end_lineno), 'magenta'),
73
- ' ' * 2
74
- ))
75
- r.write('\n')
76
-
77
- if include_complete_code:
78
- r.write('\n')
79
- r.write(lf.colored('[Generated Code]', 'green', styles=['bold']))
80
- r.write('\n\n')
81
- r.write(lf.colored(' ```python\n', 'green'))
82
- r.write(textwrap.indent(
83
- lf.colored(self.code, 'green'),
84
- ' ' * 2
85
- ))
86
- r.write(lf.colored('\n ```\n', 'green'))
87
- return r.getvalue()
88
-
89
-
90
- class SerializationError(RuntimeError):
91
- """Object serialization error."""
92
-
93
- def __init__(self, message: str | None, cause: Exception):
94
- self.message = message
95
- self.cause = cause
96
-
97
- def __str__(self):
98
- r = io.StringIO()
99
- cause_message = str(self.cause).rstrip()
100
- if self.message:
101
- r.write(lf.colored(self.message, 'magenta'))
102
- r.write('\n\n')
103
- r.write(
104
- lf.colored(
105
- f'{self.cause.__class__.__name__}: {cause_message}', 'magenta'
106
- )
107
- )
108
- return r.getvalue()
@@ -1,99 +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 code errors."""
15
-
16
- import unittest
17
-
18
- from langfun.core.coding.python import errors
19
- from langfun.core.coding.python import execution
20
-
21
-
22
- def code_error(code: str) -> errors.CodeError | None:
23
- try:
24
- execution.run(code, timeout=2)
25
- return None
26
- except errors.CodeError as e:
27
- return e
28
-
29
-
30
- class CodeErrorsTest(unittest.TestCase):
31
-
32
- def test_format(self):
33
- e = code_error(
34
- """
35
- x = y + 1
36
- """
37
- )
38
- self.assertIn('[Generated Code]', str(e))
39
- self.assertNotIn(
40
- '[Generated Code]', e.format(include_complete_code=False))
41
-
42
- def test_lineno(self):
43
- self.assertEqual(
44
- code_error(
45
- """
46
- x = y + 1
47
- """
48
- ).lineno, 1)
49
- self.assertEqual(
50
- code_error(
51
- """
52
- x = 1
53
- for i of x:
54
- y = i
55
- """
56
- ).lineno, 2)
57
- self.assertEqual(
58
- code_error(
59
- """
60
- x = 1
61
- y = 2
62
- raise ValueError
63
- """
64
- ).lineno, 3)
65
-
66
- def test_lineno_in_error_message(self):
67
- def assert_lineno(code):
68
- e = code_error(code)
69
- self.assertIn('line', e.format(include_complete_code=False))
70
-
71
- assert_lineno(
72
- """
73
- x = y + 1
74
- """
75
- )
76
- assert_lineno(
77
- """
78
- x = 1
79
- y = 2
80
- """
81
- )
82
- assert_lineno(
83
- """
84
- raise ValueError()
85
- """
86
- )
87
-
88
-
89
- class SerializationErrorTest(unittest.TestCase):
90
-
91
- def test_str(self):
92
- e = errors.SerializationError(
93
- 'Output cannot be serialized.', ValueError('abc'))
94
- self.assertIn('Output cannot be serialized', str(e))
95
- self.assertIn('ValueError: abc', str(e))
96
-
97
-
98
- if __name__ == '__main__':
99
- unittest.main()
@@ -1,90 +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
- """Python code permissions."""
15
-
16
- import contextlib
17
- import enum
18
- import pyglove as pg
19
-
20
-
21
- class CodePermission(enum.Flag):
22
- """Permissions for code execution."""
23
-
24
- # Allows basic Python code: Creating objects, assignment, operations.
25
- BASIC = enum.auto()
26
-
27
- # Allows conditions.
28
- CONDITION = enum.auto()
29
-
30
- # Allows loops.
31
- LOOP = enum.auto()
32
-
33
- # Allows exception.
34
- EXCEPTION = enum.auto()
35
-
36
- # Allows class definitions.
37
- CLASS_DEFINITION = enum.auto()
38
-
39
- # Allows function definitions.
40
- FUNCTION_DEFINITION = enum.auto()
41
-
42
- # Allows import.
43
- IMPORT = enum.auto()
44
-
45
- @classmethod
46
- @property
47
- def ALL(cls) -> 'CodePermission': # pylint: disable=invalid-name
48
- """Returns all permissions."""
49
- return (
50
- CodePermission.BASIC | CodePermission.CONDITION | CodePermission.LOOP |
51
- CodePermission.EXCEPTION | CodePermission.CLASS_DEFINITION |
52
- CodePermission.FUNCTION_DEFINITION | CodePermission.IMPORT)
53
-
54
-
55
- _TLS_CODE_RUN_PERMISSION = '__code_run_permission__'
56
-
57
-
58
- @contextlib.contextmanager
59
- def permission(perm: CodePermission):
60
- """Context manager for controling the permission for code execution.
61
-
62
- When the `permission` context manager is nested, the outtermost permission
63
- will be used. This design allows users to control permission at the top level.
64
-
65
- Args:
66
- perm: Code execution permission.
67
-
68
- Yields:
69
- Actual permission applied.
70
- """
71
-
72
- outter_perm = pg.object_utils.thread_local_get(_TLS_CODE_RUN_PERMISSION, None)
73
-
74
- # Use the top-level permission as the actual permission
75
- if outter_perm is not None:
76
- perm = outter_perm
77
-
78
- pg.object_utils.thread_local_set(_TLS_CODE_RUN_PERMISSION, perm)
79
-
80
- try:
81
- yield perm
82
- finally:
83
- if outter_perm is None:
84
- pg.object_utils.thread_local_del(_TLS_CODE_RUN_PERMISSION)
85
-
86
-
87
- def get_permission() -> CodePermission:
88
- """Gets the current permission for code execution."""
89
- return pg.object_utils.thread_local_get(
90
- _TLS_CODE_RUN_PERMISSION, CodePermission.ALL)
@@ -1,86 +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 Python code permissions."""
15
-
16
- import unittest
17
- from langfun.core.coding.python import permissions
18
-
19
-
20
- class CodePermissionTest(unittest.TestCase):
21
-
22
- def assert_set(
23
- self,
24
- permission: permissions.CodePermission,
25
- flag: permissions.CodePermission,
26
- ):
27
- self.assertEqual(permission & flag, flag)
28
-
29
- def assert_not_set(
30
- self,
31
- permission: permissions.CodePermission,
32
- flag: permissions.CodePermission,
33
- ):
34
- self.assertFalse(permission & flag)
35
-
36
- def test_all(self):
37
- self.assert_set(
38
- permissions.CodePermission.ALL, permissions.CodePermission.BASIC
39
- )
40
- self.assert_set(
41
- permissions.CodePermission.ALL, permissions.CodePermission.CONDITION
42
- )
43
- self.assert_set(
44
- permissions.CodePermission.ALL, permissions.CodePermission.LOOP
45
- )
46
- self.assert_set(
47
- permissions.CodePermission.ALL, permissions.CodePermission.EXCEPTION
48
- )
49
- self.assert_set(
50
- permissions.CodePermission.ALL,
51
- permissions.CodePermission.CLASS_DEFINITION,
52
- )
53
- self.assert_set(
54
- permissions.CodePermission.ALL,
55
- permissions.CodePermission.FUNCTION_DEFINITION,
56
- )
57
- self.assert_set(
58
- permissions.CodePermission.ALL, permissions.CodePermission.IMPORT
59
- )
60
-
61
- def test_xor(self):
62
- self.assert_not_set(
63
- permissions.CodePermission.ALL ^ permissions.CodePermission.BASIC,
64
- permissions.CodePermission.BASIC,
65
- )
66
- self.assert_set(
67
- permissions.CodePermission.ALL ^ permissions.CodePermission.BASIC,
68
- permissions.CodePermission.CONDITION,
69
- )
70
-
71
- def test_permission_control(self):
72
- self.assertEqual(
73
- permissions.get_permission(), permissions.CodePermission.ALL
74
- )
75
- with permissions.permission(permissions.CodePermission.BASIC):
76
- self.assertEqual(
77
- permissions.get_permission(), permissions.CodePermission.BASIC
78
- )
79
- with permissions.permission(permissions.CodePermission.ALL):
80
- self.assertEqual(
81
- permissions.get_permission(), permissions.CodePermission.BASIC
82
- )
83
-
84
-
85
- if __name__ == '__main__':
86
- unittest.main()