| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
Add the credit_card custom type Add a credit_card type to outlines.types matching payment card numbers for the common networks (Visa, Mastercard, American Express, Diners Club, Discover, JCB, Maestro and UnionPay) by issuer prefix and length. It validates the number format only, not the Luhn digit, so constraining generation to a card number no longer needs a hand-written regex. | 1 个月前 | |
test(dsl): fold the Literal-key case into test_dsl_handle_dict Same assertion shape as the dict[int, str] block right above it, just a different dict_type, so it reads better as another case in the existing test than as a separate one. | 1 个月前 | |
fix(types): map JSON Schema const to a Literal schema_type_to_python handled enum but not its singular sibling const, so a const field silently fell through to Any (or, when a type keyword was also present, widened to that bare type). Pydantic serialises a one-element Literal as {"const": ..., "type": ...}, so converting such a schema to a typeddict/dataclass lost the fixed value. Map const to Literal[value], before the type handling so const wins when both are present. | 2 个月前 | |
Update test_to_regex_simple for {0,n} at_most output The QuantifyMaximum assertion in test_to_regex.py still expected the old (a){,2} form; align it with the (a){0,2} output. | 2 个月前 | |
fix(types): get_enum_from_literal/get_enum_from_choice drop values that collide under str() Both functions built their Enum's name->value mapping with `{str(x): x for x in values}`. Since str(1) == str("1") == "1", Literal["1", 1] or Choice(["1", 1]) silently collapsed to a single enum member -- whichever value came last in iteration order won, the other was overwritten in the dict comprehension before Enum ever saw it. Reachable in production via models/gemini.py's structured-output enum construction (Gemini text/x.enum response schemas) for any Literal/Choice mixing a string and a numeric value that happen to stringify the same way. Fix: only disambiguate when a genuine str()-collision is detected, prefixing the colliding values' keys with their type name (e.g. "str_1" vs "int_1"). Non-colliding values keep their original str()-based member name unchanged, preserving existing behavior and the existing test's attribute-access assertions (getattr(complex_enum, "1"), "True", "None", etc.). Added two new tests covering the str()-collision case for both functions, verifying both values survive as distinct members. TDD red->green verified: reverting only utils.py reproduces `{1} == {1, '1'}` (the string value silently dropped); reapplying passes. Full tests/types/ suite: 234 passed. ruff/mypy clean via pre-commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> | 1 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 个月前 | ||
| 1 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 1 个月前 |