langfun 0.1.2.dev202409250804__py3-none-any.whl → 0.1.2.dev202409280804__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/concurrent.py +89 -39
- langfun/core/concurrent_test.py +8 -5
- langfun/core/eval/base.py +10 -1
- langfun/core/eval/matching.py +1 -2
- langfun/core/eval/scoring.py +1 -2
- langfun/core/language_model.py +2 -2
- langfun/core/llms/__init__.py +6 -0
- langfun/core/llms/vertexai.py +49 -2
- langfun/core/sampling.py +11 -11
- {langfun-0.1.2.dev202409250804.dist-info → langfun-0.1.2.dev202409280804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202409250804.dist-info → langfun-0.1.2.dev202409280804.dist-info}/RECORD +14 -14
- {langfun-0.1.2.dev202409250804.dist-info → langfun-0.1.2.dev202409280804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202409250804.dist-info → langfun-0.1.2.dev202409280804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202409250804.dist-info → langfun-0.1.2.dev202409280804.dist-info}/top_level.txt +0 -0
langfun/core/concurrent.py
CHANGED
@@ -34,7 +34,7 @@ progress_bar: Literal['tqdm', 'console', None] = None
|
|
34
34
|
try:
|
35
35
|
from tqdm import auto as tqdm # pylint: disable=g-import-not-at-top
|
36
36
|
progress_bar = 'tqdm'
|
37
|
-
except ImportError
|
37
|
+
except ImportError:
|
38
38
|
progress_bar = 'console'
|
39
39
|
tqdm = None
|
40
40
|
|
@@ -57,7 +57,7 @@ class RetryError(RuntimeError):
|
|
57
57
|
def __init__(
|
58
58
|
self,
|
59
59
|
func: Callable[..., Any],
|
60
|
-
errors: list[
|
60
|
+
errors: list[BaseException],
|
61
61
|
wait_intervals: list[int],
|
62
62
|
):
|
63
63
|
assert len(errors) == len(wait_intervals) + 1
|
@@ -112,8 +112,8 @@ class RetryError(RuntimeError):
|
|
112
112
|
def with_retry(
|
113
113
|
func: Callable[[Any], Any],
|
114
114
|
retry_on_errors: Union[
|
115
|
-
Union[Type[
|
116
|
-
Sequence[Union[Type[
|
115
|
+
Union[Type[BaseException], Tuple[Type[BaseException], str]],
|
116
|
+
Sequence[Union[Type[BaseException], Tuple[Type[BaseException], str]]],
|
117
117
|
],
|
118
118
|
max_attempts: int,
|
119
119
|
retry_interval: int | tuple[int, int] = (5, 60),
|
@@ -186,8 +186,8 @@ def concurrent_execute(
|
|
186
186
|
executor: Union[concurrent.futures.ThreadPoolExecutor, str, None] = None,
|
187
187
|
max_workers: int = 32,
|
188
188
|
retry_on_errors: Union[
|
189
|
-
Union[Type[
|
190
|
-
Sequence[Union[Type[
|
189
|
+
Union[Type[BaseException], Tuple[Type[BaseException], str]],
|
190
|
+
Sequence[Union[Type[BaseException], Tuple[Type[BaseException], str]]],
|
191
191
|
None,
|
192
192
|
] = None,
|
193
193
|
max_attempts: int = 5,
|
@@ -251,34 +251,31 @@ class Job:
|
|
251
251
|
func: Callable[[Any], Any]
|
252
252
|
arg: Any
|
253
253
|
result: Any = pg.MISSING_VALUE
|
254
|
-
|
255
|
-
|
256
|
-
|
254
|
+
timeit: pg.object_utils.TimeIt = dataclasses.field(
|
255
|
+
default_factory=lambda: pg.object_utils.TimeIt('job')
|
256
|
+
)
|
257
|
+
|
258
|
+
@property
|
259
|
+
def elapse(self) -> float:
|
260
|
+
"""Returns the running time in seconds since the job get started."""
|
261
|
+
return self.timeit.elapse
|
262
|
+
|
263
|
+
@property
|
264
|
+
def error(self) -> BaseException | None:
|
265
|
+
"""Returns the error if the job failed."""
|
266
|
+
return self.timeit.error
|
257
267
|
|
258
268
|
def __call__(self) -> Any:
|
259
|
-
self.start_time = time.time()
|
260
269
|
try:
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
270
|
+
with self.timeit:
|
271
|
+
self.result = self.func(self.arg)
|
272
|
+
return self.result
|
273
|
+
except BaseException as e: # pylint: disable=broad-exception-caught
|
265
274
|
return e
|
266
|
-
finally:
|
267
|
-
self.end_time = time.time()
|
268
275
|
|
269
|
-
def mark_canceled(self, error:
|
276
|
+
def mark_canceled(self, error: BaseException) -> None:
|
270
277
|
"""Marks the job as canceled."""
|
271
|
-
self.error
|
272
|
-
self.end_time = time.time()
|
273
|
-
|
274
|
-
@property
|
275
|
-
def elapse(self) -> float:
|
276
|
-
"""Returns the running time in seconds since the job get started."""
|
277
|
-
if self.start_time is None:
|
278
|
-
return 0.0
|
279
|
-
if self.end_time is None:
|
280
|
-
return time.time() - self.start_time
|
281
|
-
return self.end_time - self.start_time
|
278
|
+
self.timeit.end(error)
|
282
279
|
|
283
280
|
|
284
281
|
@dataclasses.dataclass
|
@@ -286,11 +283,34 @@ class Progress:
|
|
286
283
|
"""Concurrent processing progress."""
|
287
284
|
total: int
|
288
285
|
|
286
|
+
@dataclasses.dataclass
|
287
|
+
class TimeItSummary:
|
288
|
+
"""Execution details for each `pg.timeit`."""
|
289
|
+
|
290
|
+
num_started: int = 0
|
291
|
+
num_ended: int = 0
|
292
|
+
num_failed: int = 0
|
293
|
+
avg_duration: float = 0.0
|
294
|
+
|
295
|
+
def aggregate(self, status: pg.object_utils.TimeIt.Status):
|
296
|
+
self.avg_duration = (
|
297
|
+
(self.avg_duration * self.num_started + status.elapse)
|
298
|
+
/ (self.num_started + 1)
|
299
|
+
)
|
300
|
+
self.num_started += 1
|
301
|
+
if status.has_ended:
|
302
|
+
self.num_ended += 1
|
303
|
+
if status.has_error:
|
304
|
+
self.num_failed += 1
|
305
|
+
|
289
306
|
_succeeded: int = 0
|
290
307
|
_failed: int = 0
|
291
|
-
_last_error:
|
308
|
+
_last_error: BaseException | None = None
|
292
309
|
_total_duration: float = 0.0
|
293
310
|
_job: Job | None = None
|
311
|
+
_timeit_summary: dict[str, TimeItSummary] = dataclasses.field(
|
312
|
+
default_factory=dict
|
313
|
+
)
|
294
314
|
|
295
315
|
@property
|
296
316
|
def succeeded(self) -> int:
|
@@ -308,7 +328,7 @@ class Progress:
|
|
308
328
|
return self.succeeded + self.failed
|
309
329
|
|
310
330
|
@property
|
311
|
-
def last_error(self) ->
|
331
|
+
def last_error(self) -> BaseException | None:
|
312
332
|
"""Returns last error."""
|
313
333
|
return self._last_error
|
314
334
|
|
@@ -338,6 +358,28 @@ class Progress:
|
|
338
358
|
return 0.0
|
339
359
|
return self._total_duration / self.completed
|
340
360
|
|
361
|
+
@property
|
362
|
+
def timeit_summary(self) -> dict[str, TimeItSummary]:
|
363
|
+
"""Returns the aggregated summary for each `pg.timeit`."""
|
364
|
+
return self._timeit_summary
|
365
|
+
|
366
|
+
def timeit_summary_str(self) -> str | None:
|
367
|
+
if not self.timeit_summary:
|
368
|
+
return None
|
369
|
+
return ', '.join([
|
370
|
+
'%s (%.2fs, %d/%d)' % (
|
371
|
+
k, v.avg_duration, v.num_ended, v.num_started
|
372
|
+
) for k, v in self.timeit_summary.items()
|
373
|
+
])
|
374
|
+
|
375
|
+
def last_error_str(self) -> str | None:
|
376
|
+
if self.last_error is None:
|
377
|
+
return None
|
378
|
+
error_text = repr(self.last_error)
|
379
|
+
if len(error_text) >= 64:
|
380
|
+
error_text = error_text[:64] + '...'
|
381
|
+
return error_text
|
382
|
+
|
341
383
|
def update(self, job: Job) -> None:
|
342
384
|
"""Mark a job as completed."""
|
343
385
|
self._job = job
|
@@ -347,6 +389,14 @@ class Progress:
|
|
347
389
|
self._failed += 1
|
348
390
|
self._last_error = job.error
|
349
391
|
self._total_duration += job.elapse
|
392
|
+
self.merge_timeit_summary(job)
|
393
|
+
|
394
|
+
def merge_timeit_summary(self, job: Job):
|
395
|
+
for child in job.timeit.children:
|
396
|
+
for name, status in child.status().items():
|
397
|
+
if name not in self._timeit_summary:
|
398
|
+
self._timeit_summary[name] = Progress.TimeItSummary()
|
399
|
+
self._timeit_summary[name].aggregate(status)
|
350
400
|
|
351
401
|
|
352
402
|
class ProgressBar:
|
@@ -498,17 +548,17 @@ def concurrent_map(
|
|
498
548
|
status_fn: Callable[[Progress], dict[str, Any]] | None = None,
|
499
549
|
timeout: int | None = None,
|
500
550
|
silence_on_errors: Union[
|
501
|
-
Type[
|
551
|
+
Type[BaseException], Tuple[Type[BaseException], ...], None
|
502
552
|
] = Exception,
|
503
553
|
retry_on_errors: Union[
|
504
|
-
Type[
|
505
|
-
Tuple[Type[
|
554
|
+
Type[BaseException],
|
555
|
+
Tuple[Type[BaseException], ...],
|
506
556
|
None,
|
507
557
|
] = None,
|
508
558
|
max_attempts: int = 5,
|
509
559
|
retry_interval: int | tuple[int, int] = (5, 60),
|
510
560
|
exponential_backoff: bool = True,
|
511
|
-
) -> Iterator[tuple[Any, Any,
|
561
|
+
) -> Iterator[tuple[Any, Any, BaseException | None]]:
|
512
562
|
"""Maps inputs to outptus via func concurrently under current context.
|
513
563
|
|
514
564
|
Args:
|
@@ -608,13 +658,13 @@ def concurrent_map(
|
|
608
658
|
if show_progress:
|
609
659
|
status = status_fn(progress)
|
610
660
|
status.update({
|
611
|
-
'AvgDuration': '%.
|
661
|
+
'AvgDuration': '%.2fs' % progress.avg_duration
|
612
662
|
})
|
613
663
|
if progress.last_error is not None:
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
status['
|
664
|
+
status['LastError'] = progress.last_error_str()
|
665
|
+
|
666
|
+
if progress.timeit_summary:
|
667
|
+
status['TimeIt'] = progress.timeit_summary_str()
|
618
668
|
ProgressBar.update(bar_id, delta=1, status=status)
|
619
669
|
|
620
670
|
try:
|
langfun/core/concurrent_test.py
CHANGED
@@ -529,10 +529,11 @@ class ConcurrentMapTest(unittest.TestCase):
|
|
529
529
|
|
530
530
|
def test_concurrent_map_with_showing_progress(self):
|
531
531
|
def fun(x):
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
532
|
+
with pg.timeit('foo'):
|
533
|
+
if x == 2:
|
534
|
+
raise ValueError('Intentional error.')
|
535
|
+
time.sleep(x)
|
536
|
+
return x
|
536
537
|
|
537
538
|
string_io = io.StringIO()
|
538
539
|
with contextlib.redirect_stderr(string_io):
|
@@ -549,7 +550,9 @@ class ConcurrentMapTest(unittest.TestCase):
|
|
549
550
|
(3, pg.MISSING_VALUE),
|
550
551
|
],
|
551
552
|
)
|
552
|
-
|
553
|
+
output = string_io.getvalue()
|
554
|
+
self.assertIn('100%', output)
|
555
|
+
self.assertIn('TimeIt=foo (', output)
|
553
556
|
|
554
557
|
def test_concurrent_map_with_showing_progress_and_status_fn(self):
|
555
558
|
def fun(x):
|
langfun/core/eval/base.py
CHANGED
@@ -1234,8 +1234,17 @@ class Evaluation(Evaluable):
|
|
1234
1234
|
del example, output
|
1235
1235
|
|
1236
1236
|
def _status(self, progress: lf.concurrent.Progress) -> dict[str, Any]:
|
1237
|
+
status = {'Model': self.lm.model_id}
|
1238
|
+
status.update(self._eval_status(progress))
|
1239
|
+
|
1240
|
+
if progress.last_error is not None:
|
1241
|
+
status['LastError'] = progress.last_error_str()
|
1242
|
+
if progress.timeit_summary:
|
1243
|
+
status['TimeIt'] = progress.timeit_summary_str()
|
1244
|
+
return status
|
1245
|
+
|
1246
|
+
def _eval_status(self, progress: lf.concurrent.Progress) -> dict[str, Any]:
|
1237
1247
|
return {
|
1238
|
-
'Model': self.lm.model_id,
|
1239
1248
|
'Succeeded': '%s (%d/%d)' % (
|
1240
1249
|
self._format_rate(progress.success_rate),
|
1241
1250
|
progress.succeeded,
|
langfun/core/eval/matching.py
CHANGED
@@ -115,10 +115,9 @@ class Matching(base.Evaluation):
|
|
115
115
|
"""Matches answer against the groundtruth. Subclasses can override."""
|
116
116
|
return pg.eq(answer, groundtruth)
|
117
117
|
|
118
|
-
def
|
118
|
+
def _eval_status(self, progress: lf.concurrent.Progress) -> dict[str, Any]:
|
119
119
|
del progress
|
120
120
|
return {
|
121
|
-
'Model': self.lm.model_id,
|
122
121
|
'Matches': '%s (%d/%d)' % (
|
123
122
|
self._format_rate(self.match_rate),
|
124
123
|
self.num_matches,
|
langfun/core/eval/scoring.py
CHANGED
@@ -79,10 +79,9 @@ class Scoring(base.Evaluation):
|
|
79
79
|
def score(self, example: Any, output: Any) -> float:
|
80
80
|
"""Scores the output against its input example."""
|
81
81
|
|
82
|
-
def
|
82
|
+
def _eval_status(self, progress: lf.concurrent.Progress) -> dict[str, Any]:
|
83
83
|
del progress
|
84
84
|
return {
|
85
|
-
'Model': self.lm.model_id,
|
86
85
|
'Average Score': {self.avg_score},
|
87
86
|
'Scored': '%.2f%% (%d/%d)' % (
|
88
87
|
self.score_rate * 100,
|
langfun/core/language_model.py
CHANGED
@@ -508,8 +508,8 @@ class LanguageModel(component.Component):
|
|
508
508
|
inputs: Sequence[Any],
|
509
509
|
retry_on_errors: Union[
|
510
510
|
None,
|
511
|
-
Union[Type[
|
512
|
-
Sequence[Union[Type[
|
511
|
+
Union[Type[BaseException], Tuple[Type[BaseException], str]],
|
512
|
+
Sequence[Union[Type[BaseException], Tuple[Type[BaseException], str]]],
|
513
513
|
] = RetryableLMError,
|
514
514
|
) -> Any:
|
515
515
|
"""Helper method for subclasses for implementing _sample."""
|
langfun/core/llms/__init__.py
CHANGED
@@ -103,9 +103,15 @@ from langfun.core.llms.groq import GroqGemma7B_IT
|
|
103
103
|
|
104
104
|
from langfun.core.llms.vertexai import VertexAI
|
105
105
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5
|
106
|
+
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_Latest
|
107
|
+
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_001
|
108
|
+
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_002
|
106
109
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_0514
|
107
110
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_0409
|
111
|
+
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5_Latest
|
108
112
|
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5
|
113
|
+
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5_001
|
114
|
+
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5_002
|
109
115
|
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5_0514
|
110
116
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1
|
111
117
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1Vision
|
langfun/core/llms/vertexai.py
CHANGED
@@ -41,8 +41,14 @@ except ImportError:
|
|
41
41
|
|
42
42
|
|
43
43
|
SUPPORTED_MODELS_AND_SETTINGS = {
|
44
|
-
'gemini-1.5-pro-001': pg.Dict(api='gemini', rpm=
|
45
|
-
'gemini-1.5-
|
44
|
+
'gemini-1.5-pro-001': pg.Dict(api='gemini', rpm=500),
|
45
|
+
'gemini-1.5-pro-002': pg.Dict(api='gemini', rpm=500),
|
46
|
+
'gemini-1.5-flash-002': pg.Dict(api='gemini', rpm=500),
|
47
|
+
'gemini-1.5-flash-001': pg.Dict(api='gemini', rpm=500),
|
48
|
+
'gemini-1.5-pro': pg.Dict(api='gemini', rpm=500),
|
49
|
+
'gemini-1.5-flash': pg.Dict(api='gemini', rpm=500),
|
50
|
+
'gemini-1.5-pro-latest': pg.Dict(api='gemini', rpm=500),
|
51
|
+
'gemini-1.5-flash-latest': pg.Dict(api='gemini', rpm=500),
|
46
52
|
'gemini-1.5-pro-preview-0514': pg.Dict(api='gemini', rpm=50),
|
47
53
|
'gemini-1.5-pro-preview-0409': pg.Dict(api='gemini', rpm=50),
|
48
54
|
'gemini-1.5-flash-preview-0514': pg.Dict(api='gemini', rpm=200),
|
@@ -417,9 +423,30 @@ _PDF = [
|
|
417
423
|
]
|
418
424
|
|
419
425
|
|
426
|
+
class VertexAIGeminiPro1_5_Latest(VertexAI): # pylint: disable=invalid-name
|
427
|
+
"""Vertex AI Gemini 1.5 Pro model."""
|
428
|
+
|
429
|
+
model = 'gemini-1.5-pro-latest'
|
430
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
431
|
+
|
432
|
+
|
420
433
|
class VertexAIGeminiPro1_5(VertexAI): # pylint: disable=invalid-name
|
421
434
|
"""Vertex AI Gemini 1.5 Pro model."""
|
422
435
|
|
436
|
+
model = 'gemini-1.5-pro'
|
437
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
438
|
+
|
439
|
+
|
440
|
+
class VertexAIGeminiPro1_5_002(VertexAI): # pylint: disable=invalid-name
|
441
|
+
"""Vertex AI Gemini 1.5 Pro model."""
|
442
|
+
|
443
|
+
model = 'gemini-1.5-pro-002'
|
444
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
445
|
+
|
446
|
+
|
447
|
+
class VertexAIGeminiPro1_5_001(VertexAI): # pylint: disable=invalid-name
|
448
|
+
"""Vertex AI Gemini 1.5 Pro model."""
|
449
|
+
|
423
450
|
model = 'gemini-1.5-pro-001'
|
424
451
|
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
425
452
|
|
@@ -438,7 +465,27 @@ class VertexAIGeminiPro1_5_0409(VertexAI): # pylint: disable=invalid-name
|
|
438
465
|
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
439
466
|
|
440
467
|
|
468
|
+
class VertexAIGeminiFlash1_5_Latest(VertexAI): # pylint: disable=invalid-name
|
469
|
+
"""Vertex AI Gemini 1.5 Flash model."""
|
470
|
+
|
471
|
+
model = 'gemini-1.5-flash-latest'
|
472
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
473
|
+
|
474
|
+
|
441
475
|
class VertexAIGeminiFlash1_5(VertexAI): # pylint: disable=invalid-name
|
476
|
+
"""Vertex AI Gemini 1.5 Flash model."""
|
477
|
+
model = 'gemini-1.5-flash'
|
478
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
479
|
+
|
480
|
+
|
481
|
+
class VertexAIGeminiFlash1_5_002(VertexAI): # pylint: disable=invalid-name
|
482
|
+
"""Vertex AI Gemini 1.5 Flash model."""
|
483
|
+
|
484
|
+
model = 'gemini-1.5-flash-002'
|
485
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
486
|
+
|
487
|
+
|
488
|
+
class VertexAIGeminiFlash1_5_001(VertexAI): # pylint: disable=invalid-name
|
442
489
|
"""Vertex AI Gemini 1.5 Flash model."""
|
443
490
|
model = 'gemini-1.5-flash-001'
|
444
491
|
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
langfun/core/sampling.py
CHANGED
@@ -28,14 +28,14 @@ def sweep(
|
|
28
28
|
*,
|
29
29
|
max_workers: int = 32,
|
30
30
|
silence_on_errors: Union[
|
31
|
-
Type[
|
31
|
+
Type[BaseException], Tuple[Type[BaseException], ...], None
|
32
32
|
] = None,
|
33
33
|
ignore_examples_with_errors: bool = True,
|
34
34
|
**kwargs,
|
35
35
|
) -> Iterator[
|
36
36
|
Tuple[
|
37
|
-
message_lib.Message |
|
38
|
-
Union[message_lib.Message,
|
37
|
+
message_lib.Message | BaseException, # LM input.
|
38
|
+
Union[message_lib.Message, BaseException, None], # LM output.
|
39
39
|
],
|
40
40
|
]:
|
41
41
|
"""Sweeps the input/output of this LangFunc concurrently.
|
@@ -73,15 +73,15 @@ def random_sample(
|
|
73
73
|
*,
|
74
74
|
max_workers: int = 32,
|
75
75
|
silence_on_errors: Union[
|
76
|
-
Type[
|
76
|
+
Type[BaseException], Tuple[Type[BaseException], ...], None
|
77
77
|
] = None,
|
78
78
|
ignore_examples_with_errors: bool = True,
|
79
79
|
seed: int | None = None,
|
80
80
|
**kwargs,
|
81
81
|
) -> Iterator[
|
82
82
|
Tuple[
|
83
|
-
message_lib.Message |
|
84
|
-
Union[message_lib.Message,
|
83
|
+
message_lib.Message | BaseException, # LM input.
|
84
|
+
Union[message_lib.Message, BaseException, None], # LM output.
|
85
85
|
],
|
86
86
|
]:
|
87
87
|
"""Random samples the input/output of this LangFunc concurrently.
|
@@ -121,14 +121,14 @@ def _concurrent_sample(
|
|
121
121
|
*,
|
122
122
|
max_workers: int = 32,
|
123
123
|
silence_on_errors: Union[
|
124
|
-
Type[
|
124
|
+
Type[BaseException], Tuple[Type[BaseException], ...], None
|
125
125
|
] = None,
|
126
126
|
ignore_examples_with_errors: bool = True,
|
127
127
|
**kwargs,
|
128
128
|
) -> Generator[
|
129
129
|
Tuple[
|
130
|
-
message_lib.Message |
|
131
|
-
Union[message_lib.Message,
|
130
|
+
message_lib.Message | BaseException, # LM input.
|
131
|
+
Union[message_lib.Message, BaseException, None], # LM output.
|
132
132
|
],
|
133
133
|
None,
|
134
134
|
None, # Sender type and return type.
|
@@ -177,6 +177,6 @@ def _concurrent_sample(
|
|
177
177
|
else:
|
178
178
|
lm_input, lm_output = error, error
|
179
179
|
if (not ignore_examples_with_errors
|
180
|
-
or not (isinstance(lm_input,
|
181
|
-
or isinstance(lm_output,
|
180
|
+
or not (isinstance(lm_input, BaseException)
|
181
|
+
or isinstance(lm_output, BaseException))):
|
182
182
|
yield lm_input, lm_output
|
@@ -2,13 +2,13 @@ langfun/__init__.py,sha256=mCES7t3R7Z-ZQYvG38-yrVqZubrXNfGCa8tI5HGB7mE,2274
|
|
2
2
|
langfun/core/__init__.py,sha256=gKoZrxwxdR_UweutfeeECUEL6ogcr8lKk9ub5_9NaM0,4884
|
3
3
|
langfun/core/component.py,sha256=nxF4UD7NLduPjrf4IAtysMAIg3IChfoQHjY77vC8f_E,10263
|
4
4
|
langfun/core/component_test.py,sha256=q15Xn51cVTu2RKxZ9U5VQgT3bm6RQ4638bKhWBtvW5o,8220
|
5
|
-
langfun/core/concurrent.py,sha256=
|
6
|
-
langfun/core/concurrent_test.py,sha256
|
5
|
+
langfun/core/concurrent.py,sha256=QW-LbgF555lwHYmnirYONVjpqgkn95CuQRuAErgYIIY,29598
|
6
|
+
langfun/core/concurrent_test.py,sha256=F9kQKK0D6CHOejckFcVjCB-ThkBN8Oa4P8WV7FOhxIM,17042
|
7
7
|
langfun/core/console.py,sha256=bk5rNPNm9rMGW5YT2HixxU04p2umnoabn5SDz6Dqe88,2317
|
8
8
|
langfun/core/console_test.py,sha256=5SYJdxpJGLgdSSQqqMPoA1X6jpsLD8rgcyk-EgI65oE,1077
|
9
9
|
langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,11140
|
10
10
|
langfun/core/langfunc_test.py,sha256=ZLlj6ysNIWUlm0jcq6PbNUwdJ2XstW5QQT0L2s5GlGY,8753
|
11
|
-
langfun/core/language_model.py,sha256=
|
11
|
+
langfun/core/language_model.py,sha256=7z1Go39NvrP8dg52la2m56Acg3jsk-hA9m-27hUPorA,26302
|
12
12
|
langfun/core/language_model_test.py,sha256=ebJ1vnaxKSKvlwi6v07yHjn91xMiDw2bQ9DBnyVorYw,23303
|
13
13
|
langfun/core/logging.py,sha256=wYDuPuGeS1hyJBzjMQgquyfLw-TUVO-b7H68UA8X-Eg,4279
|
14
14
|
langfun/core/logging_test.py,sha256=poSsNGKi6G9LWOcWnTY0BQjj0BtaQknH-NK6FcQrVT4,2152
|
@@ -21,7 +21,7 @@ langfun/core/natural_language.py,sha256=3ynSnaYQnjE60LIPK5fyMgdIjubnPYZwzGq4rWPe
|
|
21
21
|
langfun/core/natural_language_test.py,sha256=LHGU_1ytbkGuSZQFIFP7vP3dBlcY4-A12fT6dbjUA0E,1424
|
22
22
|
langfun/core/repr_utils.py,sha256=yyc2xeK8sKQOOLcxwIV9E50Wf-B0TjXrnS07tSx_ea8,6491
|
23
23
|
langfun/core/repr_utils_test.py,sha256=ULG7gvgoyqQFWi0m6g2-E0GorNEr1nnZ0J_sZVQKz80,3036
|
24
|
-
langfun/core/sampling.py,sha256=
|
24
|
+
langfun/core/sampling.py,sha256=SCnS5PFJWNVxSKvSkSCNRUmruvScun8UcNN4gafuXcw,5866
|
25
25
|
langfun/core/sampling_test.py,sha256=U7PANpMsl9E_pa4_Y4FzesSjcwg-u-LKHGCWSgv-8FY,3663
|
26
26
|
langfun/core/subscription.py,sha256=euawEuSZP-BHydaT-AQpfYFL0m5pWPGcW0upFhrojqc,10930
|
27
27
|
langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIcArBo,8717
|
@@ -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=Ogdr9OtTywhhLPHi3AZzOD2mXX2oyaHWflrSTMm96uA,1899
|
47
|
-
langfun/core/eval/base.py,sha256=
|
47
|
+
langfun/core/eval/base.py,sha256=3ALt5L51C7jnulLuJMw2uhEvB01d-GNuG-9iMtxM4ic,75230
|
48
48
|
langfun/core/eval/base_test.py,sha256=iL-EEGnBD_HigClBwo34HVyOycupgw9r4S61eIZMShI,26929
|
49
|
-
langfun/core/eval/matching.py,sha256=
|
49
|
+
langfun/core/eval/matching.py,sha256=KooNeNQFFV56sFbSAdn-kmXuJc2Nj4LEd6rwVJ6lYgY,10033
|
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=
|
53
|
+
langfun/core/eval/scoring.py,sha256=wZz90Iw5Sco3cAiA1T71cJEWhD6qmvMeE1Ai-pez_aY,6210
|
54
54
|
langfun/core/eval/scoring_test.py,sha256=O8olHbrUEg60gMxwOkWzKBJZpZoUlmVnBANX5Se2SXM,4546
|
55
|
-
langfun/core/llms/__init__.py,sha256=
|
55
|
+
langfun/core/llms/__init__.py,sha256=lmOl2HoUYDeAnSJjObd9DfhEuchfvmrJ-GeKTbVFqds,5427
|
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=gCHBYBLvBCsC78HI1hpoqXCS-p1FMTgY1P1qh_sGBPk,3070
|
@@ -67,7 +67,7 @@ langfun/core/llms/openai.py,sha256=vnDrKuD-pli0AtDIDq_TmlltOk7z7_PQ-xpU4K1ARdU,1
|
|
67
67
|
langfun/core/llms/openai_test.py,sha256=UcBFW_7RkkMEo47Tn5RuVRK_DryTN7bb9ITphlzthE8,17762
|
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
|
70
|
-
langfun/core/llms/vertexai.py,sha256=
|
70
|
+
langfun/core/llms/vertexai.py,sha256=3w3EhGt-mF1JJmHK8X5I0PAPqLSEDIj520OayZdr-nc,16876
|
71
71
|
langfun/core/llms/vertexai_test.py,sha256=EPR-mB2hNUpvpf7E8m_k5bh04epdQTVUuYU6hPgZyu8,10321
|
72
72
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
73
73
|
langfun/core/llms/cache/base.py,sha256=rt3zwmyw0y9jsSGW-ZbV1vAfLxQ7_3AVk0l2EySlse4,3918
|
@@ -119,8 +119,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
119
119
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
120
120
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
121
121
|
langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
|
122
|
-
langfun-0.1.2.
|
123
|
-
langfun-0.1.2.
|
124
|
-
langfun-0.1.2.
|
125
|
-
langfun-0.1.2.
|
126
|
-
langfun-0.1.2.
|
122
|
+
langfun-0.1.2.dev202409280804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
123
|
+
langfun-0.1.2.dev202409280804.dist-info/METADATA,sha256=_wBVve9ZKBMFFLBTmeY-LwjHbpJHKVaejKyZv9dGVsM,8890
|
124
|
+
langfun-0.1.2.dev202409280804.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
125
|
+
langfun-0.1.2.dev202409280804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
126
|
+
langfun-0.1.2.dev202409280804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202409250804.dist-info → langfun-0.1.2.dev202409280804.dist-info}/top_level.txt
RENAMED
File without changes
|