langfun 0.1.2.dev202510200805__py3-none-any.whl → 0.1.2.dev202511160804__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.

Files changed (146) hide show
  1. langfun/core/__init__.py +1 -0
  2. langfun/core/agentic/action.py +107 -12
  3. langfun/core/agentic/action_eval.py +9 -2
  4. langfun/core/agentic/action_test.py +25 -0
  5. langfun/core/async_support.py +32 -3
  6. langfun/core/coding/python/correction.py +19 -9
  7. langfun/core/coding/python/execution.py +14 -12
  8. langfun/core/coding/python/generation.py +21 -16
  9. langfun/core/coding/python/sandboxing.py +23 -3
  10. langfun/core/component.py +42 -3
  11. langfun/core/concurrent.py +70 -6
  12. langfun/core/concurrent_test.py +1 -0
  13. langfun/core/console.py +1 -1
  14. langfun/core/data/conversion/anthropic.py +12 -3
  15. langfun/core/data/conversion/anthropic_test.py +8 -6
  16. langfun/core/data/conversion/gemini.py +9 -2
  17. langfun/core/data/conversion/gemini_test.py +12 -9
  18. langfun/core/data/conversion/openai.py +145 -31
  19. langfun/core/data/conversion/openai_test.py +161 -17
  20. langfun/core/eval/base.py +48 -44
  21. langfun/core/eval/base_test.py +4 -4
  22. langfun/core/eval/matching.py +5 -2
  23. langfun/core/eval/patching.py +3 -3
  24. langfun/core/eval/scoring.py +4 -3
  25. langfun/core/eval/v2/__init__.py +1 -0
  26. langfun/core/eval/v2/checkpointing.py +39 -5
  27. langfun/core/eval/v2/checkpointing_test.py +1 -1
  28. langfun/core/eval/v2/eval_test_helper.py +97 -1
  29. langfun/core/eval/v2/evaluation.py +88 -16
  30. langfun/core/eval/v2/evaluation_test.py +9 -3
  31. langfun/core/eval/v2/example.py +45 -39
  32. langfun/core/eval/v2/example_test.py +3 -3
  33. langfun/core/eval/v2/experiment.py +51 -8
  34. langfun/core/eval/v2/metric_values.py +31 -3
  35. langfun/core/eval/v2/metric_values_test.py +32 -0
  36. langfun/core/eval/v2/metrics.py +157 -44
  37. langfun/core/eval/v2/metrics_test.py +39 -18
  38. langfun/core/eval/v2/progress.py +30 -1
  39. langfun/core/eval/v2/progress_test.py +27 -0
  40. langfun/core/eval/v2/progress_tracking_test.py +3 -0
  41. langfun/core/eval/v2/reporting.py +90 -71
  42. langfun/core/eval/v2/reporting_test.py +20 -6
  43. langfun/core/eval/v2/runners/__init__.py +26 -0
  44. langfun/core/eval/v2/{runners.py → runners/base.py} +22 -124
  45. langfun/core/eval/v2/runners/debug.py +40 -0
  46. langfun/core/eval/v2/runners/debug_test.py +79 -0
  47. langfun/core/eval/v2/runners/parallel.py +100 -0
  48. langfun/core/eval/v2/runners/parallel_test.py +98 -0
  49. langfun/core/eval/v2/runners/sequential.py +47 -0
  50. langfun/core/eval/v2/runners/sequential_test.py +175 -0
  51. langfun/core/langfunc.py +45 -130
  52. langfun/core/langfunc_test.py +6 -4
  53. langfun/core/language_model.py +103 -16
  54. langfun/core/language_model_test.py +9 -3
  55. langfun/core/llms/__init__.py +7 -1
  56. langfun/core/llms/anthropic.py +157 -2
  57. langfun/core/llms/azure_openai.py +29 -17
  58. langfun/core/llms/cache/base.py +25 -3
  59. langfun/core/llms/cache/in_memory.py +48 -7
  60. langfun/core/llms/cache/in_memory_test.py +14 -4
  61. langfun/core/llms/compositional.py +25 -1
  62. langfun/core/llms/deepseek.py +30 -2
  63. langfun/core/llms/fake.py +32 -1
  64. langfun/core/llms/gemini.py +14 -9
  65. langfun/core/llms/google_genai.py +29 -1
  66. langfun/core/llms/groq.py +28 -3
  67. langfun/core/llms/llama_cpp.py +23 -4
  68. langfun/core/llms/openai.py +36 -3
  69. langfun/core/llms/openai_compatible.py +148 -27
  70. langfun/core/llms/openai_compatible_test.py +207 -20
  71. langfun/core/llms/openai_test.py +0 -2
  72. langfun/core/llms/rest.py +12 -1
  73. langfun/core/llms/vertexai.py +51 -8
  74. langfun/core/logging.py +1 -1
  75. langfun/core/mcp/client.py +77 -22
  76. langfun/core/mcp/client_test.py +8 -35
  77. langfun/core/mcp/session.py +94 -29
  78. langfun/core/mcp/session_test.py +54 -0
  79. langfun/core/mcp/tool.py +151 -22
  80. langfun/core/mcp/tool_test.py +197 -0
  81. langfun/core/memory.py +1 -0
  82. langfun/core/message.py +160 -55
  83. langfun/core/message_test.py +65 -81
  84. langfun/core/modalities/__init__.py +8 -0
  85. langfun/core/modalities/audio.py +21 -1
  86. langfun/core/modalities/image.py +19 -1
  87. langfun/core/modalities/mime.py +62 -3
  88. langfun/core/modalities/pdf.py +19 -1
  89. langfun/core/modalities/video.py +21 -1
  90. langfun/core/modality.py +167 -29
  91. langfun/core/modality_test.py +42 -12
  92. langfun/core/natural_language.py +1 -1
  93. langfun/core/sampling.py +4 -4
  94. langfun/core/sampling_test.py +20 -4
  95. langfun/core/structured/__init__.py +2 -24
  96. langfun/core/structured/completion.py +34 -44
  97. langfun/core/structured/completion_test.py +23 -43
  98. langfun/core/structured/description.py +54 -50
  99. langfun/core/structured/function_generation.py +29 -12
  100. langfun/core/structured/mapping.py +81 -37
  101. langfun/core/structured/parsing.py +95 -79
  102. langfun/core/structured/parsing_test.py +0 -3
  103. langfun/core/structured/querying.py +215 -142
  104. langfun/core/structured/querying_test.py +65 -29
  105. langfun/core/structured/schema/__init__.py +48 -0
  106. langfun/core/structured/schema/base.py +664 -0
  107. langfun/core/structured/schema/base_test.py +531 -0
  108. langfun/core/structured/schema/json.py +174 -0
  109. langfun/core/structured/schema/json_test.py +121 -0
  110. langfun/core/structured/schema/python.py +316 -0
  111. langfun/core/structured/schema/python_test.py +410 -0
  112. langfun/core/structured/schema_generation.py +33 -14
  113. langfun/core/structured/scoring.py +47 -36
  114. langfun/core/structured/tokenization.py +26 -11
  115. langfun/core/subscription.py +2 -2
  116. langfun/core/template.py +175 -50
  117. langfun/core/template_test.py +123 -17
  118. langfun/env/__init__.py +8 -2
  119. langfun/env/base_environment.py +320 -128
  120. langfun/env/base_environment_test.py +473 -0
  121. langfun/env/base_feature.py +92 -15
  122. langfun/env/base_feature_test.py +228 -0
  123. langfun/env/base_sandbox.py +84 -361
  124. langfun/env/base_sandbox_test.py +1235 -0
  125. langfun/env/event_handlers/__init__.py +1 -1
  126. langfun/env/event_handlers/chain.py +233 -0
  127. langfun/env/event_handlers/chain_test.py +253 -0
  128. langfun/env/event_handlers/event_logger.py +95 -98
  129. langfun/env/event_handlers/event_logger_test.py +21 -21
  130. langfun/env/event_handlers/metric_writer.py +225 -140
  131. langfun/env/event_handlers/metric_writer_test.py +23 -6
  132. langfun/env/interface.py +854 -40
  133. langfun/env/interface_test.py +112 -2
  134. langfun/env/load_balancers_test.py +23 -2
  135. langfun/env/test_utils.py +126 -84
  136. {langfun-0.1.2.dev202510200805.dist-info → langfun-0.1.2.dev202511160804.dist-info}/METADATA +1 -1
  137. langfun-0.1.2.dev202511160804.dist-info/RECORD +211 -0
  138. langfun/core/eval/v2/runners_test.py +0 -343
  139. langfun/core/structured/schema.py +0 -987
  140. langfun/core/structured/schema_test.py +0 -982
  141. langfun/env/base_test.py +0 -1481
  142. langfun/env/event_handlers/base.py +0 -350
  143. langfun-0.1.2.dev202510200805.dist-info/RECORD +0 -195
  144. {langfun-0.1.2.dev202510200805.dist-info → langfun-0.1.2.dev202511160804.dist-info}/WHEEL +0 -0
  145. {langfun-0.1.2.dev202510200805.dist-info → langfun-0.1.2.dev202511160804.dist-info}/licenses/LICENSE +0 -0
  146. {langfun-0.1.2.dev202510200805.dist-info → langfun-0.1.2.dev202511160804.dist-info}/top_level.txt +0 -0
@@ -31,30 +31,32 @@ class MetricWriterTest(unittest.TestCase):
31
31
  pool_size=2,
32
32
  outage_grace_period=0,
33
33
  outage_retry_interval=0,
34
- housekeep_interval=0.0,
34
+ housekeep_interval=10.0,
35
35
  sandbox_keepalive_interval=1.0,
36
- event_handlers=[writer],
36
+ event_handler=writer,
37
37
  )
38
38
  with env:
39
- with env.sandbox('session1') as sb:
39
+ with env.sandbox(session_id='session1') as sb:
40
40
  self.assertEqual(sb.test_feature1.num_shell_calls(), 4)
41
41
 
42
42
  with self.assertRaises(interface.SandboxStateError):
43
- with env.sandbox('session2') as sb:
43
+ with env.sandbox(session_id='session2') as sb:
44
44
  sb.shell('echo "bar"', raise_error=RuntimeError)
45
45
 
46
- self.assertEqual(
46
+ self.assertIn(
47
47
  writer._sandbox_start.value(
48
48
  app='test_app',
49
49
  environment_id='testing-env',
50
+ image_id='test_image',
50
51
  error='Success'
51
52
  ),
52
- 2
53
+ (2, 3)
53
54
  )
54
55
  self.assertGreater(
55
56
  writer._sandbox_housekeep.value(
56
57
  app='test_app',
57
58
  environment_id='testing-env',
59
+ image_id='test_image',
58
60
  error='Success'
59
61
  ),
60
62
  0,
@@ -63,6 +65,7 @@ class MetricWriterTest(unittest.TestCase):
63
65
  writer._sandbox_shutdown.value(
64
66
  app='test_app',
65
67
  environment_id='testing-env',
68
+ image_id='test_image',
66
69
  error='Success'
67
70
  ),
68
71
  2
@@ -71,6 +74,7 @@ class MetricWriterTest(unittest.TestCase):
71
74
  writer._sandbox_count.value(
72
75
  app='test_app',
73
76
  environment_id='testing-env',
77
+ image_id='test_image',
74
78
  status='ready',
75
79
  ),
76
80
  0
@@ -79,6 +83,7 @@ class MetricWriterTest(unittest.TestCase):
79
83
  writer._sandbox_count.value(
80
84
  app='test_app',
81
85
  environment_id='testing-env',
86
+ image_id='test_image',
82
87
  status='offline',
83
88
  ),
84
89
  0
@@ -87,6 +92,7 @@ class MetricWriterTest(unittest.TestCase):
87
92
  writer._feature_setup.value(
88
93
  app='test_app',
89
94
  environment_id='testing-env',
95
+ image_id='test_image',
90
96
  feature_name='test_feature1',
91
97
  error='Success'
92
98
  ),
@@ -96,6 +102,7 @@ class MetricWriterTest(unittest.TestCase):
96
102
  writer._feature_setup.value(
97
103
  app='test_app',
98
104
  environment_id='testing-env',
105
+ image_id='test_image',
99
106
  feature_name='test_feature2',
100
107
  error='Success'
101
108
  ),
@@ -105,6 +112,7 @@ class MetricWriterTest(unittest.TestCase):
105
112
  writer._feature_setup_session.value(
106
113
  app='test_app',
107
114
  environment_id='testing-env',
115
+ image_id='test_image',
108
116
  feature_name='test_feature1',
109
117
  error='Success'
110
118
  ),
@@ -114,6 +122,7 @@ class MetricWriterTest(unittest.TestCase):
114
122
  writer._feature_setup_session.value(
115
123
  app='test_app',
116
124
  environment_id='testing-env',
125
+ image_id='test_image',
117
126
  feature_name='test_feature2',
118
127
  error='Success'
119
128
  ),
@@ -123,6 +132,7 @@ class MetricWriterTest(unittest.TestCase):
123
132
  writer._feature_teardown_session.value(
124
133
  app='test_app',
125
134
  environment_id='testing-env',
135
+ image_id='test_image',
126
136
  feature_name='test_feature1',
127
137
  error='Success'
128
138
  ),
@@ -132,6 +142,7 @@ class MetricWriterTest(unittest.TestCase):
132
142
  writer._feature_teardown_session.value(
133
143
  app='test_app',
134
144
  environment_id='testing-env',
145
+ image_id='test_image',
135
146
  feature_name='test_feature2',
136
147
  error='Success'
137
148
  ),
@@ -141,6 +152,7 @@ class MetricWriterTest(unittest.TestCase):
141
152
  writer._feature_teardown.value(
142
153
  app='test_app',
143
154
  environment_id='testing-env',
155
+ image_id='test_image',
144
156
  feature_name='test_feature1',
145
157
  error='Success'
146
158
  ),
@@ -150,6 +162,7 @@ class MetricWriterTest(unittest.TestCase):
150
162
  writer._feature_teardown.value(
151
163
  app='test_app',
152
164
  environment_id='testing-env',
165
+ image_id='test_image',
153
166
  feature_name='test_feature2',
154
167
  error='Success'
155
168
  ),
@@ -159,6 +172,7 @@ class MetricWriterTest(unittest.TestCase):
159
172
  writer._feature_housekeep.value(
160
173
  app='test_app',
161
174
  environment_id='testing-env',
175
+ image_id='test_image',
162
176
  feature_name='test_feature1',
163
177
  error='Success'
164
178
  ),
@@ -168,6 +182,7 @@ class MetricWriterTest(unittest.TestCase):
168
182
  writer._feature_housekeep.value(
169
183
  app='test_app',
170
184
  environment_id='testing-env',
185
+ image_id='test_image',
171
186
  feature_name='test_feature2',
172
187
  error='Success'
173
188
  ),
@@ -177,6 +192,7 @@ class MetricWriterTest(unittest.TestCase):
177
192
  writer._sandbox_activity.value(
178
193
  app='test_app',
179
194
  environment_id='testing-env',
195
+ image_id='test_image',
180
196
  activity='shell',
181
197
  error='Success'
182
198
  ),
@@ -186,6 +202,7 @@ class MetricWriterTest(unittest.TestCase):
186
202
  writer._sandbox_activity.value(
187
203
  app='test_app',
188
204
  environment_id='testing-env',
205
+ image_id='test_image',
189
206
  activity='shell',
190
207
  error='RuntimeError'
191
208
  ),