langfun 0.1.2.dev202412170805__py3-none-any.whl → 0.1.2.dev202412230804__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/__init__.py +3 -0
- langfun/core/eval/v2/checkpointing.py +193 -62
- langfun/core/eval/v2/checkpointing_test.py +4 -3
- langfun/core/eval/v2/evaluation.py +80 -6
- langfun/core/eval/v2/evaluation_test.py +27 -14
- langfun/core/eval/v2/experiment.py +12 -4
- langfun/core/eval/v2/progress_tracking_test.py +4 -4
- langfun/core/eval/v2/reporting.py +104 -29
- langfun/core/eval/v2/reporting_test.py +2 -2
- langfun/core/eval/v2/runners.py +79 -38
- langfun/core/eval/v2/runners_test.py +10 -9
- langfun/core/llms/vertexai.py +1 -1
- langfun/core/logging.py +19 -0
- langfun/core/logging_test.py +19 -0
- langfun/core/structured/__init__.py +2 -0
- langfun/core/structured/parsing.py +24 -17
- langfun/core/structured/parsing_test.py +25 -0
- langfun/core/structured/querying.py +257 -69
- langfun/core/structured/querying_test.py +97 -0
- langfun/core/structured/schema.py +2 -12
- {langfun-0.1.2.dev202412170805.dist-info → langfun-0.1.2.dev202412230804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202412170805.dist-info → langfun-0.1.2.dev202412230804.dist-info}/RECORD +26 -26
- /langfun/core/eval/v2/{test_helper.py → eval_test_helper.py} +0 -0
- {langfun-0.1.2.dev202412170805.dist-info → langfun-0.1.2.dev202412230804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202412170805.dist-info → langfun-0.1.2.dev202412230804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202412170805.dist-info → langfun-0.1.2.dev202412230804.dist-info}/top_level.txt +0 -0
@@ -105,12 +105,11 @@ def _query_structure_cls(
|
|
105
105
|
|
106
106
|
def query(
|
107
107
|
prompt: Union[str, lf.Template, Any],
|
108
|
-
schema:
|
109
|
-
schema_lib.Schema, Type[Any], list[Type[Any]], dict[str, Any], None
|
110
|
-
] = None,
|
108
|
+
schema: schema_lib.SchemaType | None = None,
|
111
109
|
default: Any = lf.RAISE_IF_HAS_ERROR,
|
112
110
|
*,
|
113
|
-
lm: lf.LanguageModel | None = None,
|
111
|
+
lm: lf.LanguageModel | list[lf.LanguageModel] | None = None,
|
112
|
+
num_samples: int | list[int] = 1,
|
114
113
|
examples: list[mapping.MappingExample] | None = None,
|
115
114
|
cache_seed: int | None = 0,
|
116
115
|
response_postprocess: Callable[[str], str] | None = None,
|
@@ -121,76 +120,207 @@ def query(
|
|
121
120
|
skip_lm: bool = False,
|
122
121
|
**kwargs,
|
123
122
|
) -> Any:
|
124
|
-
"""
|
123
|
+
"""Query one or more language models for structured or unstructured outputs.
|
124
|
+
|
125
|
+
This is the primary API in Langfun for interacting with language models,
|
126
|
+
supporting natural language prompts, structured inputs, and multiple advanced
|
127
|
+
features.
|
128
|
+
|
129
|
+
Key Features:
|
130
|
+
|
131
|
+
- **Input**: Accepts natural language strings, structured inputs (e.g.,
|
132
|
+
`pg.Object`), and templates (`lf.Template`) with modality objects.
|
133
|
+
|
134
|
+
- **Output**: Returns structured outputs when `schema` is specified;
|
135
|
+
otherwise, outputs raw natural language (as a string).
|
136
|
+
|
137
|
+
- **Few-shot examples**: Supports structured few-shot examples with the
|
138
|
+
`examples` argument.
|
139
|
+
|
140
|
+
- **Multi-LM fan-out**: Sends queries to multiple language models with in
|
141
|
+
multiple samples in parallel, returning a list of outputs.
|
125
142
|
|
126
143
|
Examples:
|
127
144
|
|
145
|
+
Case 1: Regular natural language-based LLM query:
|
146
|
+
|
147
|
+
```
|
148
|
+
lf.query('1 + 1 = ?', lm=lf.llms.Gpt4Turbo())
|
149
|
+
|
150
|
+
# Outptut: '2'
|
151
|
+
```
|
152
|
+
|
153
|
+
Case 2: Query with structured output.
|
154
|
+
|
128
155
|
```
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
156
|
+
lf.query('1 + 1 = ?', int, lm=lf.llms.Gpt4Turbo())
|
157
|
+
|
158
|
+
# Output: 2
|
159
|
+
```
|
160
|
+
|
161
|
+
Case 3: Query with structured input.
|
162
|
+
|
163
|
+
```
|
164
|
+
class Sum(pg.Object):
|
165
|
+
a: int
|
166
|
+
b: int
|
167
|
+
|
168
|
+
lf.query(Sum(1, 1), int, lm=lf.llms.Gpt4Turbo())
|
169
|
+
|
170
|
+
# Output: 2
|
171
|
+
```
|
172
|
+
|
173
|
+
Case 4: Query with input of mixed modalities.
|
174
|
+
|
175
|
+
```
|
176
|
+
class Animal(pg.Object):
|
177
|
+
pass
|
178
|
+
|
179
|
+
class Dog(Animal):
|
180
|
+
pass
|
181
|
+
|
182
|
+
class Entity(pg.Object):
|
183
|
+
name: str
|
184
|
+
|
185
|
+
lf.query(
|
186
|
+
'What is in this {{image}} and {{objects}}?'
|
187
|
+
list[Entity],
|
188
|
+
lm=lf.llms.Gpt4Turbo()
|
189
|
+
image=lf.Image(path='/path/to/a/airplane.png'),
|
190
|
+
objects=[Dog()],
|
191
|
+
)
|
192
|
+
|
193
|
+
# Output: [Entity(name='airplane'), Entity(name='dog')]
|
194
|
+
```
|
195
|
+
|
196
|
+
Case 5: Query with structured few-shot examples.
|
197
|
+
```
|
198
|
+
lf.query(
|
199
|
+
'What is in this {{image}} and {{objects}}?'
|
200
|
+
list[Entity],
|
201
|
+
lm=lf.llms.Gpt4Turbo()
|
202
|
+
image=lf.Image(path='/path/to/a/dinasaur.png'),
|
203
|
+
objects=[Dog()],
|
204
|
+
examples=[
|
205
|
+
lf.MappingExample(
|
206
|
+
input=lf.Template(
|
207
|
+
'What is the object near the house in this {{image}}?',
|
208
|
+
image=lf.Image(path='/path/to/image.png'),
|
209
|
+
),
|
210
|
+
schema=Entity,
|
211
|
+
output=Entity('cat'),
|
212
|
+
),
|
213
|
+
],
|
214
|
+
)
|
215
|
+
|
216
|
+
# Output: [Entity(name='dinasaur'), Entity(name='dog')]
|
217
|
+
```
|
218
|
+
|
219
|
+
Case 6: Multiple queries to multiple models.
|
220
|
+
```
|
221
|
+
lf.query(
|
222
|
+
'1 + 1 = ?',
|
223
|
+
int,
|
224
|
+
lm=[
|
225
|
+
lf.llms.Gpt4Turbo(),
|
226
|
+
lf.llms.Gemini1_5Pro(),
|
227
|
+
],
|
228
|
+
num_samples=[1, 2],
|
229
|
+
)
|
230
|
+
# Output: [2, 2, 2]
|
153
231
|
```
|
154
232
|
|
155
233
|
Args:
|
156
|
-
prompt:
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
be
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
-
|
234
|
+
prompt: The input query. Can be:
|
235
|
+
- A natural language string (supports templating with `{{}}`),
|
236
|
+
- A `pg.Object` object for structured input,
|
237
|
+
- An `lf.Template` for mixed or template-based inputs.
|
238
|
+
schema: Type annotation or `lf.Schema` object for the expected output.
|
239
|
+
If `None` (default), the response will be a natural language string.
|
240
|
+
default: Default value to return if parsing fails. If not specified, an
|
241
|
+
error will be raised.
|
242
|
+
lm: The language model(s) to query. Can be:
|
243
|
+
- A single `LanguageModel`,
|
244
|
+
- A list of `LanguageModel`s for multi-model fan-out.
|
245
|
+
If `None`, the LM from `lf.context` will be used.
|
246
|
+
num_samples: Number of samples to generate. If a list is provided, its
|
247
|
+
length must match the number of models in `lm`.
|
248
|
+
examples: Few-shot examples to guide the model output. Defaults to `None`.
|
249
|
+
cache_seed: Seed for caching the query. Queries with the same
|
250
|
+
`(lm, prompt, cache_seed)` will use cached responses. If `None`,
|
251
|
+
caching is disabled.
|
252
|
+
response_postprocess: A post-processing function for the raw LM response.
|
253
|
+
If `None`, no post-processing occurs.
|
254
|
+
autofix: Number of attempts for auto-fixing code errors. Set to `0` to
|
255
|
+
disable auto-fixing. Not supported with the `'json'` protocol.
|
256
|
+
autofix_lm: The LM to use for auto-fixing. Defaults to the `autofix_lm`
|
257
|
+
from `lf.context` or the main `lm`.
|
258
|
+
protocol: Format for schema representation. Choices are `'json'` or
|
259
|
+
`'python'`. Default is `'python'`.
|
260
|
+
returns_message: If `True`, returns an `lf.Message` object instead of
|
261
|
+
the final parsed result.
|
262
|
+
skip_lm: If `True`, skips the LLM call and returns the rendered
|
263
|
+
prompt as a `UserMessage` object.
|
264
|
+
**kwargs: Additional keyword arguments for:
|
265
|
+
- Rendering templates (e.g., `template_str`, `preamble`),
|
266
|
+
- Configuring `lf.structured.Mapping`.
|
188
267
|
|
189
268
|
Returns:
|
190
|
-
The result
|
269
|
+
The result of the query:
|
270
|
+
- A single output or a list of outputs if multiple models/samples are used.
|
271
|
+
- Each output is a parsed object matching `schema`, an `lf.Message` (if
|
272
|
+
`returns_message=True`), or a natural language string (default).
|
191
273
|
"""
|
192
274
|
# Internal usage logging.
|
193
275
|
|
276
|
+
# Multiple quries will be issued when `lm` is a list or `num_samples` is
|
277
|
+
# greater than 1.
|
278
|
+
if isinstance(lm, list) or num_samples != 1:
|
279
|
+
def _single_query(inputs):
|
280
|
+
lm, example_i = inputs
|
281
|
+
return query(
|
282
|
+
prompt,
|
283
|
+
schema,
|
284
|
+
default=default,
|
285
|
+
lm=lm,
|
286
|
+
examples=examples,
|
287
|
+
# Usually num_examples should not be large, so we multiple the user
|
288
|
+
# provided cache seed by 100 to avoid collision.
|
289
|
+
cache_seed=(
|
290
|
+
None if cache_seed is None else cache_seed * 100 + example_i
|
291
|
+
),
|
292
|
+
response_postprocess=response_postprocess,
|
293
|
+
autofix=autofix,
|
294
|
+
autofix_lm=autofix_lm,
|
295
|
+
protocol=protocol,
|
296
|
+
returns_message=returns_message,
|
297
|
+
skip_lm=skip_lm,
|
298
|
+
**kwargs,
|
299
|
+
)
|
300
|
+
lm_list = lm if isinstance(lm, list) else [lm]
|
301
|
+
num_samples_list = (
|
302
|
+
num_samples if isinstance(num_samples, list)
|
303
|
+
else [num_samples] * len(lm_list)
|
304
|
+
)
|
305
|
+
assert len(lm_list) == len(num_samples_list), (
|
306
|
+
'Expect the length of `num_samples` to be the same as the '
|
307
|
+
f'the length of `lm`. Got {num_samples} and {lm_list}.'
|
308
|
+
)
|
309
|
+
query_inputs = []
|
310
|
+
total_queries = 0
|
311
|
+
for lm, num_samples in zip(lm_list, num_samples_list):
|
312
|
+
query_inputs.extend([(lm, i) for i in range(num_samples)])
|
313
|
+
total_queries += num_samples
|
314
|
+
|
315
|
+
samples = []
|
316
|
+
for _, output, error in lf.concurrent_map(
|
317
|
+
_single_query, query_inputs, max_workers=max(64, total_queries),
|
318
|
+
ordered=True,
|
319
|
+
):
|
320
|
+
if error is None:
|
321
|
+
samples.append(output)
|
322
|
+
return samples
|
323
|
+
|
194
324
|
# Normalize query schema.
|
195
325
|
# When `lf.query` is used for symbolic completion, schema is automatically
|
196
326
|
# inferred when it is None.
|
@@ -280,11 +410,52 @@ def query(
|
|
280
410
|
return output_message if returns_message else _result(output_message)
|
281
411
|
|
282
412
|
|
413
|
+
#
|
414
|
+
# Helper function for map-reduce style querying.
|
415
|
+
#
|
416
|
+
|
417
|
+
|
418
|
+
def query_and_reduce(
|
419
|
+
prompt: Union[str, lf.Template, Any],
|
420
|
+
schema: schema_lib.SchemaType | None = None,
|
421
|
+
*,
|
422
|
+
reduce: Callable[[list[Any]], Any],
|
423
|
+
lm: lf.LanguageModel | list[lf.LanguageModel] | None = None,
|
424
|
+
num_samples: int | list[int] = 1,
|
425
|
+
**kwargs,
|
426
|
+
) -> Any:
|
427
|
+
"""Issues multiple `lf.query` calls in parallel and reduce the outputs.
|
428
|
+
|
429
|
+
Args:
|
430
|
+
prompt: A str (may contain {{}} as template) as natural language input, or a
|
431
|
+
`pg.Symbolic` object as structured input as prompt to LLM.
|
432
|
+
schema: A type annotation as the schema for output object. If str (default),
|
433
|
+
the response will be a str in natural language.
|
434
|
+
reduce: A function to reduce the outputs of multiple `lf.query` calls. It
|
435
|
+
takes a list of outputs and returns the final object.
|
436
|
+
lm: The language model to use. If not specified, the language model from
|
437
|
+
`lf.context` context manager will be used.
|
438
|
+
num_samples: The number of samples to obtain from each language model being
|
439
|
+
requested. If a list is provided, it should have the same length as `lm`.
|
440
|
+
**kwargs: Additional arguments to pass to `lf.query`.
|
441
|
+
|
442
|
+
Returns:
|
443
|
+
The reduced output from multiple `lf.query` calls.
|
444
|
+
"""
|
445
|
+
results = query(prompt, schema, lm=lm, num_samples=num_samples, **kwargs)
|
446
|
+
if isinstance(results, list):
|
447
|
+
results = reduce(results)
|
448
|
+
return results
|
449
|
+
|
450
|
+
|
451
|
+
#
|
452
|
+
# Functions for decomposing `lf.query` into pre-llm and post-llm operations.
|
453
|
+
#
|
454
|
+
|
455
|
+
|
283
456
|
def query_prompt(
|
284
457
|
prompt: Union[str, lf.Template, Any],
|
285
|
-
schema:
|
286
|
-
schema_lib.Schema, Type[Any], list[Type[Any]], dict[str, Any], None
|
287
|
-
] = None,
|
458
|
+
schema: schema_lib.SchemaType | None = None,
|
288
459
|
**kwargs,
|
289
460
|
) -> lf.Message:
|
290
461
|
"""Returns the final prompt sent to LLM for `lf.query`."""
|
@@ -295,9 +466,7 @@ def query_prompt(
|
|
295
466
|
|
296
467
|
def query_output(
|
297
468
|
response: Union[str, lf.Message],
|
298
|
-
schema:
|
299
|
-
schema_lib.Schema, Type[Any], list[Type[Any]], dict[str, Any], None
|
300
|
-
],
|
469
|
+
schema: schema_lib.SchemaType | None = None,
|
301
470
|
**kwargs,
|
302
471
|
) -> Any:
|
303
472
|
"""Returns the final output of `lf.query` from a provided LLM response."""
|
@@ -308,6 +477,11 @@ def query_output(
|
|
308
477
|
)
|
309
478
|
|
310
479
|
|
480
|
+
#
|
481
|
+
# Functions for computing reward of an LLM response based on a mapping example.
|
482
|
+
#
|
483
|
+
|
484
|
+
|
311
485
|
def query_reward(
|
312
486
|
mapping_example: Union[str, mapping.MappingExample],
|
313
487
|
response: Union[str, lf.Message],
|
@@ -362,6 +536,11 @@ def _reward_fn(cls) -> Callable[
|
|
362
536
|
return _reward
|
363
537
|
|
364
538
|
|
539
|
+
#
|
540
|
+
# Functions for tracking `lf.query` invocations.
|
541
|
+
#
|
542
|
+
|
543
|
+
|
365
544
|
class QueryInvocation(pg.Object, pg.views.HtmlTreeView.Extension):
|
366
545
|
"""A class to represent the invocation of `lf.query`."""
|
367
546
|
|
@@ -404,7 +583,16 @@ class QueryInvocation(pg.Object, pg.views.HtmlTreeView.Extension):
|
|
404
583
|
|
405
584
|
@functools.cached_property
|
406
585
|
def output(self) -> Any:
|
407
|
-
|
586
|
+
"""The output of `lf.query`. If it failed, returns the `MappingError`."""
|
587
|
+
try:
|
588
|
+
return query_output(self.lm_response, self.schema)
|
589
|
+
except mapping.MappingError as e:
|
590
|
+
return e
|
591
|
+
|
592
|
+
@property
|
593
|
+
def has_error(self) -> bool:
|
594
|
+
"""Returns True if the query failed to generate a valid output."""
|
595
|
+
return isinstance(self.output, BaseException)
|
408
596
|
|
409
597
|
@property
|
410
598
|
def elapse(self) -> float:
|
@@ -327,6 +327,69 @@ class QueryTest(unittest.TestCase):
|
|
327
327
|
expected_modalities=3,
|
328
328
|
)
|
329
329
|
|
330
|
+
def test_multiple_queries(self):
|
331
|
+
self.assertEqual(
|
332
|
+
querying.query(
|
333
|
+
'Compute 1 + 2',
|
334
|
+
int,
|
335
|
+
lm=[
|
336
|
+
fake.StaticResponse('1'),
|
337
|
+
fake.StaticResponse('2'),
|
338
|
+
],
|
339
|
+
num_samples=[1, 2],
|
340
|
+
),
|
341
|
+
[1, 2, 2]
|
342
|
+
)
|
343
|
+
self.assertEqual(
|
344
|
+
querying.query(
|
345
|
+
'Compute 1 + 2',
|
346
|
+
int,
|
347
|
+
lm=[
|
348
|
+
fake.StaticResponse('1'),
|
349
|
+
fake.StaticResponse('2'),
|
350
|
+
],
|
351
|
+
num_samples=2,
|
352
|
+
),
|
353
|
+
[1, 1, 2, 2]
|
354
|
+
)
|
355
|
+
self.assertEqual(
|
356
|
+
querying.query(
|
357
|
+
'Compute 1 + 2',
|
358
|
+
int,
|
359
|
+
lm=[
|
360
|
+
fake.StaticResponse('1'),
|
361
|
+
fake.StaticResponse('abc'),
|
362
|
+
],
|
363
|
+
num_samples=[1, 2],
|
364
|
+
),
|
365
|
+
[1]
|
366
|
+
)
|
367
|
+
self.assertEqual(
|
368
|
+
querying.query(
|
369
|
+
'Compute 1 + 2',
|
370
|
+
int,
|
371
|
+
default=0,
|
372
|
+
lm=[
|
373
|
+
fake.StaticResponse('1'),
|
374
|
+
fake.StaticResponse('abc'),
|
375
|
+
],
|
376
|
+
num_samples=[1, 2],
|
377
|
+
),
|
378
|
+
[1, 0, 0]
|
379
|
+
)
|
380
|
+
results = querying.query(
|
381
|
+
'Compute 1 + 2',
|
382
|
+
int,
|
383
|
+
default=0,
|
384
|
+
lm=[
|
385
|
+
fake.StaticResponse('1'),
|
386
|
+
fake.StaticResponse('abc'),
|
387
|
+
],
|
388
|
+
returns_message=True,
|
389
|
+
)
|
390
|
+
self.assertEqual([r.text for r in results], ['1', 'abc'])
|
391
|
+
self.assertEqual([r.result for r in results], [1, 0])
|
392
|
+
|
330
393
|
def test_bad_protocol(self):
|
331
394
|
with self.assertRaisesRegex(ValueError, 'Unknown protocol'):
|
332
395
|
querying.query('what is 1 + 1', int, protocol='text')
|
@@ -393,6 +456,30 @@ class QueryTest(unittest.TestCase):
|
|
393
456
|
)
|
394
457
|
self.assertIsNotNone(output.get_modality('image'))
|
395
458
|
|
459
|
+
def test_query_and_reduce(self):
|
460
|
+
self.assertEqual(
|
461
|
+
querying.query_and_reduce(
|
462
|
+
'Compute 1 + 1',
|
463
|
+
int,
|
464
|
+
reduce=sum,
|
465
|
+
lm=[
|
466
|
+
fake.StaticResponse('1'),
|
467
|
+
fake.StaticResponse('2'),
|
468
|
+
],
|
469
|
+
num_samples=[1, 2],
|
470
|
+
),
|
471
|
+
5
|
472
|
+
)
|
473
|
+
self.assertEqual(
|
474
|
+
querying.query_and_reduce(
|
475
|
+
'Compute 1 + 1',
|
476
|
+
int,
|
477
|
+
reduce=sum,
|
478
|
+
lm=fake.StaticResponse('2'),
|
479
|
+
),
|
480
|
+
2
|
481
|
+
)
|
482
|
+
|
396
483
|
def test_query_output(self):
|
397
484
|
self.assertEqual(
|
398
485
|
querying.query_output(
|
@@ -964,6 +1051,16 @@ class QueryStructureJsonTest(unittest.TestCase):
|
|
964
1051
|
|
965
1052
|
class QueryInvocationTest(unittest.TestCase):
|
966
1053
|
|
1054
|
+
def test_basics(self):
|
1055
|
+
lm = fake.StaticSequence([
|
1056
|
+
'Activity(description="hi"',
|
1057
|
+
])
|
1058
|
+
with querying.track_queries() as queries:
|
1059
|
+
querying.query('foo', Activity, default=None, lm=lm)
|
1060
|
+
|
1061
|
+
self.assertTrue(queries[0].has_error)
|
1062
|
+
self.assertIsInstance(queries[0].output, mapping.MappingError)
|
1063
|
+
|
967
1064
|
def test_to_html(self):
|
968
1065
|
lm = fake.StaticSequence([
|
969
1066
|
'Activity(description="hi")',
|
@@ -213,18 +213,8 @@ class Schema(
|
|
213
213
|
"""
|
214
214
|
)
|
215
215
|
|
216
|
-
|
217
|
-
|
218
|
-
*,
|
219
|
-
view: pg.views.HtmlTreeView,
|
220
|
-
content: pg.Html | str | None = None,
|
221
|
-
**kwargs,
|
222
|
-
):
|
223
|
-
return view.tooltip(
|
224
|
-
self,
|
225
|
-
content=content or pg.Html.escape(self.schema_str(protocol='python')),
|
226
|
-
**kwargs
|
227
|
-
)
|
216
|
+
|
217
|
+
SchemaType = Union[Schema, Type[Any], list[Type[Any]], dict[str, Any]]
|
228
218
|
|
229
219
|
|
230
220
|
def _top_level_object_specs_from_value(value: pg.Symbolic) -> list[Type[Any]]:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
langfun/__init__.py,sha256=
|
1
|
+
langfun/__init__.py,sha256=fhfPXpHN7GoGqixpFfqhQkYxFs_siP_LhbjZhd3lhio,2497
|
2
2
|
langfun/core/__init__.py,sha256=xlvFTXc7IKUTs8aCFRFhzOLTmmeuhXgk9yx2InBLNiA,4937
|
3
3
|
langfun/core/component.py,sha256=HVrEoTL1Y01iqOHC3FYdbAOnffqfHHtGJXoK1vkdEwo,11583
|
4
4
|
langfun/core/component_test.py,sha256=sG-T2wpvBfHqWGZE7sc4NayJj2aj5QFBzSwFiwrGEIc,10376
|
@@ -10,8 +10,8 @@ langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,1114
|
|
10
10
|
langfun/core/langfunc_test.py,sha256=fKIAqcSNI_7M6nwoZW77HEam8Oa6vcWhsCNgVJanzb4,8822
|
11
11
|
langfun/core/language_model.py,sha256=b15MZ_qbydnz5vQ09t7sf9tc3C7qWvMSxUrGfT0p99I,33827
|
12
12
|
langfun/core/language_model_test.py,sha256=hnYhtw7GM_TbhgsJzHNYTaoDewUlPHpOVlI7xEkCFuI,31783
|
13
|
-
langfun/core/logging.py,sha256=
|
14
|
-
langfun/core/logging_test.py,sha256=
|
13
|
+
langfun/core/logging.py,sha256=W3mLEMXdo210Q5OX3a1ZTc4nU-xMy73-IfNKnsA-RFo,8051
|
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
|
@@ -58,13 +58,14 @@ langfun/core/eval/patching_test.py,sha256=8kCd54Egjju22FMgtJuxEsrXkW8ifs-UUBHtrC
|
|
58
58
|
langfun/core/eval/scoring.py,sha256=B69IsIxiPs1xZcOBFIhZF70YmDue2Siik-CPL2bh33s,6254
|
59
59
|
langfun/core/eval/scoring_test.py,sha256=O8olHbrUEg60gMxwOkWzKBJZpZoUlmVnBANX5Se2SXM,4546
|
60
60
|
langfun/core/eval/v2/__init__.py,sha256=qoa6zKdFXOFyCX6vay6OdgPf1eUhYGoHYAxe35qECGk,1628
|
61
|
-
langfun/core/eval/v2/checkpointing.py,sha256=
|
62
|
-
langfun/core/eval/v2/checkpointing_test.py,sha256=
|
63
|
-
langfun/core/eval/v2/
|
64
|
-
langfun/core/eval/v2/
|
61
|
+
langfun/core/eval/v2/checkpointing.py,sha256=5Koc9IM5OFAhLaO7sAZC979vEFxR8a_ssXcaqG_iVw0,10325
|
62
|
+
langfun/core/eval/v2/checkpointing_test.py,sha256=i9qmEJk90kz6SB7OBGAHCogKVyazUZxAZlKXZt9hccI,4435
|
63
|
+
langfun/core/eval/v2/eval_test_helper.py,sha256=pDpZTBnWRR5xjJv3Uy3NWEzArqlL8FTMOgeR4C53F5M,2348
|
64
|
+
langfun/core/eval/v2/evaluation.py,sha256=NFBGAWw2BtW7H0zcoZhfWtz59Psra84eshJm73uAFwg,21807
|
65
|
+
langfun/core/eval/v2/evaluation_test.py,sha256=GmV1TiqX1V15st2qpcGWooM5hudomQVjW5kajovGDvE,6231
|
65
66
|
langfun/core/eval/v2/example.py,sha256=fURrvdNmMsVMqoEErcsmLmC6Xq3ny16dYsnLH8HVlcY,9626
|
66
67
|
langfun/core/eval/v2/example_test.py,sha256=WcJmU7IQQXvjFia63mokySC4CqxzVL9Wso1sC5F0YK8,3032
|
67
|
-
langfun/core/eval/v2/experiment.py,sha256=
|
68
|
+
langfun/core/eval/v2/experiment.py,sha256=DuuqTJA0jmep-CM098MYutKkarLIcd1Do9P0W_HhdBg,29800
|
68
69
|
langfun/core/eval/v2/experiment_test.py,sha256=zSMHYqC9cA0k61U71pCSYTAJ6yK2_b6Dml5btc-bKzQ,9133
|
69
70
|
langfun/core/eval/v2/metric_values.py,sha256=_B905bC-jxrYPLSEcP2M8MaHZOVMz_bVrUw8YC4arCE,4660
|
70
71
|
langfun/core/eval/v2/metric_values_test.py,sha256=ab2oF_HsIwrSy459108ggyjgefHSPn8UVILR4dRwx14,2634
|
@@ -73,12 +74,11 @@ langfun/core/eval/v2/metrics_test.py,sha256=p4FzLJsE8XAzAQuyP9hfEf9YeKWZ__PO_ue8
|
|
73
74
|
langfun/core/eval/v2/progress.py,sha256=azZgssQgNdv3IgjKEaQBuGI5ucFDNbdi02P4z_nQ8GE,10292
|
74
75
|
langfun/core/eval/v2/progress_test.py,sha256=YU7VHzmy5knPZwj9vpBN3rQQH2tukj9eKHkuBCI62h8,2540
|
75
76
|
langfun/core/eval/v2/progress_tracking.py,sha256=l9fEkz4oP5McpZzf72Ua7PYm3lAWtRru7gRWNf8H0ms,6083
|
76
|
-
langfun/core/eval/v2/progress_tracking_test.py,sha256=
|
77
|
-
langfun/core/eval/v2/reporting.py,sha256=
|
78
|
-
langfun/core/eval/v2/reporting_test.py,sha256=
|
79
|
-
langfun/core/eval/v2/runners.py,sha256=
|
80
|
-
langfun/core/eval/v2/runners_test.py,sha256=
|
81
|
-
langfun/core/eval/v2/test_helper.py,sha256=pDpZTBnWRR5xjJv3Uy3NWEzArqlL8FTMOgeR4C53F5M,2348
|
77
|
+
langfun/core/eval/v2/progress_tracking_test.py,sha256=fouMVJkFJqHjbhQJngGLGCmA9x3n0dU4USI2dY163mg,2291
|
78
|
+
langfun/core/eval/v2/reporting.py,sha256=qFxoxqQhNGxh1APg6-JVDlIfniGdty2Rh8aXQMc1aak,6612
|
79
|
+
langfun/core/eval/v2/reporting_test.py,sha256=4nobW6pcaatiZh8u4xciexciaiZNDlDoJci157Wp_RI,1492
|
80
|
+
langfun/core/eval/v2/runners.py,sha256=t6_yHAJ4HWufK4wvh_OntKcok2KquA5ARIHIk1vvEwc,15870
|
81
|
+
langfun/core/eval/v2/runners_test.py,sha256=A37fKK2MvAVTiShsg_laluJzJ9AuAQn52k7HPbfD0Ks,11666
|
82
82
|
langfun/core/llms/__init__.py,sha256=lWXKjGHv66ShG7AE_Bc4QM7SDTxJdfoQMn3PF0lr0sU,6461
|
83
83
|
langfun/core/llms/anthropic.py,sha256=afKZmdiLcosS_UEBlB8WKyf1K-zeXgwtPAx6ofg2Gww,13989
|
84
84
|
langfun/core/llms/anthropic_test.py,sha256=-2U4kc_pgBM7wqxu8RuxzyHPGww1EAWqKUvN4PW8Btw,8058
|
@@ -96,7 +96,7 @@ langfun/core/llms/openai.py,sha256=l49v6RubfInvV0iG114AymTKNogTX4u4N-UFCeSgIxw,2
|
|
96
96
|
langfun/core/llms/openai_test.py,sha256=kOWa1nf-nJvtYY10REUw5wojh3ZgfU8tRaCZ8wUgJbA,16623
|
97
97
|
langfun/core/llms/rest.py,sha256=sWbYUV8S3SuOg9giq7xwD-xDRfaF7NP_ig7bI52-Rj4,3442
|
98
98
|
langfun/core/llms/rest_test.py,sha256=NZ3Nf0XQVpT9kLP5cBVo_yBHLI7vWTYhWQxYEJVMGs4,3472
|
99
|
-
langfun/core/llms/vertexai.py,sha256=
|
99
|
+
langfun/core/llms/vertexai.py,sha256=oEd665IBwzCTlHuLEMrCdwgQzrFB5ERcnxw6nrYNSyk,14990
|
100
100
|
langfun/core/llms/vertexai_test.py,sha256=ffcA5yPecnQy_rhkuYAw_6o1iLW8AR8FgswmHt6aAys,6725
|
101
101
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
102
102
|
langfun/core/llms/cache/base.py,sha256=rt3zwmyw0y9jsSGW-ZbV1vAfLxQ7_3AVk0l2EySlse4,3918
|
@@ -118,7 +118,7 @@ langfun/core/modalities/pdf.py,sha256=mfaeCbUA4JslFVTARiJh8hW7imvL4tLVw9gUhO5bAZ
|
|
118
118
|
langfun/core/modalities/pdf_test.py,sha256=ulZ0FbnlsU0wkrdckJ4ONZPTYRyMPO9Aob1UO6FXygk,1950
|
119
119
|
langfun/core/modalities/video.py,sha256=vI9apcHIHGyp90i34Srg7S3G6IBDtDCk8qiXhwRQmkw,967
|
120
120
|
langfun/core/modalities/video_test.py,sha256=7OXZoohKMYjt7vrJUdPb553HLyl1oBOKRgzBePFv68Q,2042
|
121
|
-
langfun/core/structured/__init__.py,sha256=
|
121
|
+
langfun/core/structured/__init__.py,sha256=3Wb4ks14D5E5z1nQ5trXSXiLqFN5E_3HvcEJQAfFRl0,3220
|
122
122
|
langfun/core/structured/completion.py,sha256=yW95Yd4wbt964I5wIyPUtIVeeqeZbA6HidLgN0ZpWm0,8110
|
123
123
|
langfun/core/structured/completion_test.py,sha256=VtYfI3ciVSSWbi8x3l1WwpWK-Ofn2DMHYEEqm2uTzhw,19314
|
124
124
|
langfun/core/structured/description.py,sha256=6BztYOiucPkF4CrTQtPLPJo1gN2dwnKmaJW83GBf4H0,5213
|
@@ -127,11 +127,11 @@ langfun/core/structured/function_generation.py,sha256=g7AOR_e8HxFU6n6Df750aGkgMg
|
|
127
127
|
langfun/core/structured/function_generation_test.py,sha256=LaXYDXf9GlqUrR6v_gtmK_H4kxzonmU7SYbn7XXMgjU,12128
|
128
128
|
langfun/core/structured/mapping.py,sha256=vLKH79UT-j0qkQdvqlQBO7SkXXuM-yr2Idm8_HH8qwM,13649
|
129
129
|
langfun/core/structured/mapping_test.py,sha256=bHm2ZCXBITq_G8Lvw_olFHeUUc4s_lGXZm9v9JhoPB4,9630
|
130
|
-
langfun/core/structured/parsing.py,sha256=
|
131
|
-
langfun/core/structured/parsing_test.py,sha256
|
132
|
-
langfun/core/structured/querying.py,sha256=
|
133
|
-
langfun/core/structured/querying_test.py,sha256=
|
134
|
-
langfun/core/structured/schema.py,sha256=
|
130
|
+
langfun/core/structured/parsing.py,sha256=MGvI7ypXlwfzr5XB8_TFU9Ei0_5reYqkWkv64eAy0EA,12015
|
131
|
+
langfun/core/structured/parsing_test.py,sha256=kNPrhpdPY3iWhUld0TFYU-Zgn44wC0d6YuQ9XdVbQ8o,22346
|
132
|
+
langfun/core/structured/querying.py,sha256=nqvsfMS_KLv5EvO0_VAGEHwY4pHy4S0CvJmeV0HBXlM,23066
|
133
|
+
langfun/core/structured/querying_test.py,sha256=YlC4s9LVChfhGZzaXGW1UYlcBnAjNOunu4SLl5_p7PQ,32054
|
134
|
+
langfun/core/structured/schema.py,sha256=0VUPSfX1JEQ0xu8WvEymCKK_WSGwBNA-rQD2hATErmU,27912
|
135
135
|
langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
|
136
136
|
langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
|
137
137
|
langfun/core/structured/schema_test.py,sha256=RjYhwTgktQgyqAjzLvo967nTiIK9KWgP-aNGg4e7ihE,25258
|
@@ -148,8 +148,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
148
148
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
149
149
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
150
150
|
langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
|
151
|
-
langfun-0.1.2.
|
152
|
-
langfun-0.1.2.
|
153
|
-
langfun-0.1.2.
|
154
|
-
langfun-0.1.2.
|
155
|
-
langfun-0.1.2.
|
151
|
+
langfun-0.1.2.dev202412230804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
152
|
+
langfun-0.1.2.dev202412230804.dist-info/METADATA,sha256=e9FV85ywSpXtalxNlCkRTRf84M9rv2aJxIm_qKESGZc,8281
|
153
|
+
langfun-0.1.2.dev202412230804.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
154
|
+
langfun-0.1.2.dev202412230804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
155
|
+
langfun-0.1.2.dev202412230804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202412170805.dist-info → langfun-0.1.2.dev202412230804.dist-info}/top_level.txt
RENAMED
File without changes
|