Skip to content

Consider injecting validator docstrings into system message #765

Description

@eb8680

Currently Skills are not automatically informed about the constraints imposed by Pydantic validator annotations in their signature. For example, guardrails.py includes two validators:

@Skill.define
def is_safe_query(user_query: str) -> bool:
    """
    Determine whether the user's query is purely related to travel advice: {user_query}
    """

def is_concise_answer(answer: str) -> bool:
    """Determine whether the answer is concise (<100 words)."""
    return len(answer.split()) < 100

@Skill.define
def travel_query(
    user_query: typing.Annotated[str, annotated_types.Predicate(is_safe_query)],
) -> typing.Annotated[str, annotated_types.Predicate(is_concise_answer)]:
    """
    Produce a concise (<100 word) answer to: {user_query}
    """

These two happen to already be visible through lexical scope, but we might want to introspect the Predicate annotations on travel_query and inject their docstrings into the system prompt so that information doesn't have to be manually duplicated in the travel_query template.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions