langfun 0.0.2.dev20240521__py3-none-any.whl → 0.0.2.dev20240523__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/llms/vertexai.py +5 -3
- langfun/core/structured/schema.py +4 -1
- langfun/core/structured/schema_test.py +15 -3
- {langfun-0.0.2.dev20240521.dist-info → langfun-0.0.2.dev20240523.dist-info}/METADATA +1 -1
- {langfun-0.0.2.dev20240521.dist-info → langfun-0.0.2.dev20240523.dist-info}/RECORD +8 -8
- {langfun-0.0.2.dev20240521.dist-info → langfun-0.0.2.dev20240523.dist-info}/LICENSE +0 -0
- {langfun-0.0.2.dev20240521.dist-info → langfun-0.0.2.dev20240523.dist-info}/WHEEL +0 -0
- {langfun-0.0.2.dev20240521.dist-info → langfun-0.0.2.dev20240523.dist-info}/top_level.txt +0 -0
langfun/core/llms/vertexai.py
CHANGED
@@ -160,14 +160,16 @@ class VertexAI(lf.LanguageModel):
|
|
160
160
|
|
161
161
|
def _sample(self, prompts: list[lf.Message]) -> list[lf.LMSamplingResult]:
|
162
162
|
assert self._api_initialized, 'Vertex AI API is not initialized.'
|
163
|
+
# TODO(yifenglu): It seems this exception is due to the instability of the
|
164
|
+
# API. We should revisit this later.
|
165
|
+
retry_on_errors = [(Exception, 'InternalServerError')]
|
166
|
+
|
163
167
|
return lf.concurrent_execute(
|
164
168
|
self._sample_single,
|
165
169
|
prompts,
|
166
170
|
executor=self.resource_id,
|
167
171
|
max_workers=self.max_concurrency,
|
168
|
-
|
169
|
-
# with rate limit, so we do not retry on errors.
|
170
|
-
retry_on_errors=None,
|
172
|
+
retry_on_errors=retry_on_errors,
|
171
173
|
)
|
172
174
|
|
173
175
|
def _sample_single(self, prompt: lf.Message) -> lf.LMSamplingResult:
|
@@ -262,7 +262,7 @@ def class_dependencies(
|
|
262
262
|
_fill_dependencies(elem.value, include_subclasses)
|
263
263
|
elif isinstance(vs, pg.typing.Dict) and vs.schema:
|
264
264
|
for v in vs.schema.values():
|
265
|
-
_fill_dependencies(v, include_subclasses)
|
265
|
+
_fill_dependencies(v.value, include_subclasses)
|
266
266
|
elif isinstance(vs, pg.typing.Union):
|
267
267
|
for v in vs.candidates:
|
268
268
|
_fill_dependencies(v, include_subclasses)
|
@@ -508,6 +508,9 @@ def annotation(
|
|
508
508
|
x = '{' + kv_str + '}'
|
509
509
|
if strict:
|
510
510
|
x = f'pg.typing.Dict({x})'
|
511
|
+
elif vs.schema and vs.schema.dynamic_field:
|
512
|
+
v = annotation(vs.schema.dynamic_field.value, strict=strict)
|
513
|
+
x = f'dict[str, {v}]'
|
511
514
|
else:
|
512
515
|
x = 'dict[str, Any]'
|
513
516
|
|
@@ -260,15 +260,18 @@ class ClassDependenciesTest(unittest.TestCase):
|
|
260
260
|
class A(pg.Object):
|
261
261
|
foo: tuple[Foo, int]
|
262
262
|
|
263
|
+
class B(pg.Object):
|
264
|
+
pass
|
265
|
+
|
263
266
|
class X(pg.Object):
|
264
|
-
k:
|
267
|
+
k: dict[str, B]
|
265
268
|
|
266
|
-
class
|
269
|
+
class C(A):
|
267
270
|
bar: Bar
|
268
271
|
foo2: Foo | X
|
269
272
|
|
270
273
|
a = A(foo=(Foo(1), 0))
|
271
|
-
self.assertEqual(schema_lib.class_dependencies(a), [Foo, A, Bar, X,
|
274
|
+
self.assertEqual(schema_lib.class_dependencies(a), [Foo, A, Bar, B, X, C])
|
272
275
|
|
273
276
|
self.assertEqual(schema_lib.class_dependencies(1), [])
|
274
277
|
|
@@ -395,6 +398,15 @@ class SchemaPythonReprTest(unittest.TestCase):
|
|
395
398
|
'dict[str, Any]',
|
396
399
|
strict=False,
|
397
400
|
)
|
401
|
+
|
402
|
+
class DictValue(pg.Object):
|
403
|
+
pass
|
404
|
+
|
405
|
+
self.assert_annotation(
|
406
|
+
pg.typing.Dict([(pg.typing.StrKey(), DictValue)]),
|
407
|
+
'dict[str, DictValue]',
|
408
|
+
strict=False,
|
409
|
+
)
|
398
410
|
self.assert_annotation(
|
399
411
|
pg.typing.Dict(),
|
400
412
|
'dict[str, Any]',
|
@@ -61,7 +61,7 @@ langfun/core/llms/llama_cpp.py,sha256=Y_KkMUf3Xfac49koMUtUslKl3h-HWp3-ntq7Jaa3bd
|
|
61
61
|
langfun/core/llms/llama_cpp_test.py,sha256=ZxC6defGd_HX9SFRU9U4cJiQnBKundbOrchbXuC1Z2M,1683
|
62
62
|
langfun/core/llms/openai.py,sha256=IN46gIqfY6aEEfxCPNmyH1hrep3oWBhJDwVFilfqNkM,13657
|
63
63
|
langfun/core/llms/openai_test.py,sha256=asSA1sVy_7hnXioD_2HTxtSDpVTKBUO_EjZuyHpwbn0,14854
|
64
|
-
langfun/core/llms/vertexai.py,sha256=
|
64
|
+
langfun/core/llms/vertexai.py,sha256=V_-dUUQAPWXff5kWt9qOWJNrigy2jQL_bRVbaz8w6hg,9635
|
65
65
|
langfun/core/llms/vertexai_test.py,sha256=1u813e2esr8HVbOpLTOhIgzaX-GqCRTBouJ1doRn80Q,7642
|
66
66
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
67
67
|
langfun/core/llms/cache/base.py,sha256=cFfYvOIUae842pncqCAsRvqXCk2AnAsRYVx0mcIoAeY,3338
|
@@ -90,10 +90,10 @@ langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGX
|
|
90
90
|
langfun/core/structured/parsing_test.py,sha256=34wDrXaQ-EYhJLfDL8mX9K53oQMSzh5pVYdKjnESmK8,20895
|
91
91
|
langfun/core/structured/prompting.py,sha256=cswl9c93edsYnXsZQmMzPpmqOuKnBzbgebTYBbSxwzo,8815
|
92
92
|
langfun/core/structured/prompting_test.py,sha256=rddf5qHN8Gm_JaNMmytwiVEBm-eZVJFLQO4GljUgR44,21700
|
93
|
-
langfun/core/structured/schema.py,sha256=
|
93
|
+
langfun/core/structured/schema.py,sha256=HDb6N7zB4z83kUYW4-ic84QgIHKpR4LZCivMeALDBVo,25967
|
94
94
|
langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
|
95
95
|
langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
|
96
|
-
langfun/core/structured/schema_test.py,sha256=
|
96
|
+
langfun/core/structured/schema_test.py,sha256=S32-fo8HblYAiGoy7zsmQrbO_P-dypaYVsH7RNPLOog,23318
|
97
97
|
langfun/core/structured/scoring.py,sha256=QyT1S8FkLtKICfUbh4AXoKK3YJ_rgejyk6TI2OtOa68,2751
|
98
98
|
langfun/core/structured/scoring_test.py,sha256=39_dw6p_FkoqeUccO67yIqos-MccAWezoozS21i8mi0,1732
|
99
99
|
langfun/core/templates/__init__.py,sha256=bO0eMsVJbi7sxEB2YlInKRQ2EVP-RyyKUwcD-8msuN4,927
|
@@ -105,8 +105,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
105
105
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
106
106
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
107
107
|
langfun/core/templates/selfplay_test.py,sha256=DYVrkk7uNKCqJGEHH31HssU2BPuMItU1vJLzfcXIlYg,2156
|
108
|
-
langfun-0.0.2.
|
109
|
-
langfun-0.0.2.
|
110
|
-
langfun-0.0.2.
|
111
|
-
langfun-0.0.2.
|
112
|
-
langfun-0.0.2.
|
108
|
+
langfun-0.0.2.dev20240523.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
109
|
+
langfun-0.0.2.dev20240523.dist-info/METADATA,sha256=_zsZALQcxxtvtRy3cH2uXRwpjUs3h-JwZ3BUR7t7HLw,3452
|
110
|
+
langfun-0.0.2.dev20240523.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
111
|
+
langfun-0.0.2.dev20240523.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
112
|
+
langfun-0.0.2.dev20240523.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|