Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patches on message support on top of history #900

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

dtam
Copy link
Contributor

@dtam dtam commented Jul 9, 2024

short circuits on="messages" to on="msg_history" to add use and use many support for the 6x interface

to test

from pydantic import BaseModel, Field
from guardrails.async_guard import AsyncGuard

class Pet(BaseModel):
    name: str = Field(description="a unique pet name")

def custom_llm(*args, **kwargs):
    raise Exception(
        "LLM was called when it should not have been!"
        "Input Validation did not raise as expected!"
    )

guard = AsyncGuard.from_pydantic(output_class=Pet)
guard.use(TwoWords(on_fail=on_fail), on="messages")
    await guard(
        custom_llm,
        messages=[
            {
                "role": "user",
                "content": "What kind of pet should I get?",
            }
        ],
    )

should raise a validation error

guardrails/run/runner.py Outdated Show resolved Hide resolved
@dtam dtam requested a review from zsimjee July 10, 2024 18:11
@zsimjee zsimjee merged commit 2337e7a into 0.5.0-dev Jul 10, 2024
12 checks passed
@zsimjee zsimjee deleted the dtam/on_message_support branch July 10, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants