text_utils
Text model group utilities for the v2 API.
Exposes the backend's text model name parsing, group member retrieval, and name composition as API endpoints for the frontend group editing UX.
GroupNameQuery
module-attribute
GroupNameQuery = Annotated[
str,
Query(
alias="name",
description="Group name; may contain '/'.",
),
]
_COMMON_FIELD_KEYS
module-attribute
_COMMON_FIELD_KEYS = (
"baseline",
"description",
"url",
"nsfw",
"tags",
"style",
"instruct_format",
)
ExtraPartInfo
Bases: BaseModel
A name segment that didn't match any primary part category.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
ParsedNameResponse
Bases: BaseModel
Structured result of parsing a text model name.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
ParsedNameInfo
Bases: BaseModel
Parsed name components for a single group member.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupMemberInfo
Bases: BaseModel
A single member of a text model group with parsed name info.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
NameFormatInfo
Bases: BaseModel
Serializable representation of an inferred name format schema.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
NameExceptionInfo
Bases: BaseModel
A member that does not follow the group naming schema.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupMembersResponse
Bases: BaseModel
Full response for a text model group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
exception_members
class-attribute
instance-attribute
DistinctBaselinesResponse
Bases: BaseModel
Response containing sorted unique baseline values for text models.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
ComposeNameRequest
Bases: BaseModel
Request body for composing a model name from parts.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
ComposeNameResponse
Bases: BaseModel
Response from the name composition endpoint.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
CommonFieldsUpdateRequest
Bases: BaseModel
Request body for batch-updating common fields across a group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
BatchUpdateResponse
Bases: BaseModel
Response from batch group common field update.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupNameSchemaResponse
Bases: BaseModel
Response for a group's naming schema.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupNameSchemaUpdateRequest
Bases: BaseModel
Partial update for a group's naming schema.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
NameExceptionRequest
Bases: BaseModel
Set or clear a name schema exception on a model.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupListResponse
GroupHealthIssue
Bases: BaseModel
A single health problem detected for a group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupSummaryEntry
Bases: BaseModel
Enriched metadata for a single text model group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupsSummaryResponse
Bases: BaseModel
Enriched overview of all text model groups.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupHealthResponse
Bases: BaseModel
Aggregate health check across all text model groups.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupAliasResponse
Bases: BaseModel
A single group alias entry.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupAliasListResponse
Bases: BaseModel
Response listing all group alias entries.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
SetAliasesRequest
Bases: BaseModel
Request body for setting the full alias list for a canonical group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
AddAliasRequest
Bases: BaseModel
Request body for adding a single alias to a canonical group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
RemoveAliasRequest
Bases: BaseModel
Request body for removing a single alias from a canonical group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupFamilyResponse
Bases: BaseModel
A single related-group family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
GroupFamilyListResponse
Bases: BaseModel
Response listing all related-group families.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
SetFamilyRequest
Bases: BaseModel
Request body for creating or replacing a family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
AddFamilyMemberRequest
Bases: BaseModel
Request body for adding a single group to a family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
RemoveFamilyMemberRequest
Bases: BaseModel
Request body for removing a single group from a family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
DetectFamiliesResponse
Bases: BaseModel
Response from auto-detection of family suggestions.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_get_all_text_models
Load all text generation models as raw dicts.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_get_group_members
_get_group_members(
all_models: dict[str, dict[str, Any]], group_name: str
) -> list[tuple[str, dict[str, Any]]]
Filter models belonging to a specific group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_compute_common_fields
Find fields that are identical across all canonical members.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_compose_name_from_parts
_compose_name_from_parts(
base_name: str,
size: str,
variant: str | None = None,
version: str | None = None,
quant: str | None = None,
author: str | None = None,
separator: str = "-",
part_order: list[str] | None = None,
) -> str
Compose a model name from structured parts.
When part_order is provided, parts are arranged in that order, using separator.
Otherwise uses default: [author/]base{sep}size[{sep}variant][{sep}version][{sep}quant]
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
parse_name
parse_name(
name: Annotated[
str, Query(description="The model name to parse")
],
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> ParsedNameResponse
Parse a text model name into base name, size, variant, and quantization components.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
get_group
get_group(
group_name: GroupNameQuery,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupMembersResponse
Get all models in a text model group with parsed name info and common fields.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
get_distinct_baselines
get_distinct_baselines(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> DistinctBaselinesResponse
Return sorted unique non-empty baselines from text_generation models.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
compose_name
compose_name(
request: ComposeNameRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> ComposeNameResponse
Compose a model name from base name, size, variant, and quant parts.
Checks whether the composed name already exists in the text_generation category.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
update_group_common_fields
async
update_group_common_fields(
group_name: GroupNameQuery,
request: CommonFieldsUpdateRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse
Update shared fields across all canonical members of a text model group.
Creates one PendingChangeRecord per canonical member with a shared batch_id.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
list_groups
list_groups(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupListResponse
Return sorted distinct text_model_group values across all text models.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_collect_group_health_issues
_collect_group_health_issues(
group_name: str,
members: list[tuple[str, dict[str, Any]]],
) -> list[GroupHealthIssue]
Check a group's canonical members for common problems.
Returns a list of issues found. Called by both the summary and health endpoints to avoid duplicating diagnostic logic.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
list_groups_summary
list_groups_summary(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupsSummaryResponse
Return per-group metadata including member counts, family/alias info, and health flags.
Designed to power a group management overview UI in a single request.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | |
check_groups_health
check_groups_health(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupHealthResponse
Scan all text model groups for common problems.
Returns an aggregate list of issues sorted by severity, useful for admin triage dashboards.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_require_group_schema_store
Return the group schema store or raise 503 if unavailable.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
get_group_name_schema
get_group_name_schema(
group_name: GroupNameQuery,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupNameSchemaResponse
Return the persisted naming schema if one exists, otherwise infer from member names.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
update_group_name_schema
async
update_group_name_schema(
group_name: GroupNameQuery,
request: GroupNameSchemaUpdateRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupNameSchemaResponse
Persist a custom naming schema for a text model group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
delete_group_name_schema
async
delete_group_name_schema(
group_name: GroupNameQuery,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> None
Remove the persisted naming schema so the group reverts to inference.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
set_name_exception
async
set_name_exception(
model_name: str,
request: NameExceptionRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> JSONResponse
Set or clear the name_schema_exception field on a text model.
Pass {"reason": "some reason"} to flag the model or {"reason": null} to clear.
Changes go through the pending queue.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_require_group_alias_store
Return the group alias store or raise 503 if unavailable.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
list_aliases
list_aliases(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupAliasListResponse
Return all configured group alias entries.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
get_alias
get_alias(
canonical: str,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupAliasResponse
Return the alias entry for a specific canonical group name.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
set_aliases
async
set_aliases(
canonical: str,
request: SetAliasesRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupAliasResponse
Replace all aliases for a canonical group name.
Raises 409 if any alias is already claimed by a different canonical group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
add_alias
async
add_alias(
canonical: str,
request: AddAliasRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupAliasResponse
Add one alias to a canonical group. Creates the entry if needed.
Raises 409 if the alias is already claimed by a different canonical group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
remove_alias
async
remove_alias(
canonical: str,
request: RemoveAliasRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupAliasResponse
Remove one alias from a canonical group.
Returns the updated entry. Raises 404 if the alias was not found.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
delete_aliases
async
delete_aliases(
canonical: str,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> None
Remove the entire alias entry for a canonical group.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
_require_group_family_store
Return the group family store or raise 503 if unavailable.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
list_families
list_families(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupFamilyListResponse
Return all configured related-group families.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
detect_family_suggestions
detect_family_suggestions(
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
min_prefix_length: Annotated[
int, Query(ge=2, le=20)
] = 3,
min_family_size: Annotated[int, Query(ge=2, le=50)] = 2,
) -> DetectFamiliesResponse
Run prefix-based heuristics over current group names to suggest families.
Results are suggestions only - they are not persisted automatically.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
get_family
get_family(
family_name: str,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
) -> GroupFamilyResponse
Return the family with the given name.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
set_family
async
set_family(
family_name: str,
request: SetFamilyRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupFamilyResponse
Create or replace a family with the given members.
Raises 409 if any member already belongs to a different family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
add_family_member
async
add_family_member(
family_name: str,
request: AddFamilyMemberRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupFamilyResponse
Add a single group to an existing family.
Raises 404 if the family does not exist, 409 if the group belongs to another family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
remove_family_member
async
remove_family_member(
family_name: str,
request: RemoveFamilyMemberRequest,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> GroupFamilyResponse
Remove a single group from a family.
If the family becomes empty, it is deleted entirely. Raises 404 if the group was not found in the family.
Source code in src/horde_model_reference/service/v2/routers/text_utils.py
delete_family
async
delete_family(
family_name: str,
manager: Annotated[
ModelReferenceManager,
Depends(get_model_reference_manager),
],
apikey: Annotated[str, Depends(header_auth_scheme)],
) -> None
Delete an entire family, releasing all its members.