new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Pydantic · Integrations · all subjects

logfire

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Pydantic Logfire integration overview

Pydantic integrates seamlessly with Pydantic Logfire, an observability platform. Logfire has an out-of-the-box Pydantic integration that lets you understand data passing through Pydantic models and get analytics on validations.

Logfire setup steps

Getting started with Logfire can be done in three simple steps: 1) Set up your Logfire account, 2) Install the Logfire SDK, 3) Instrument your project.

Basic Logfire configuration for Pydantic

The logfire.configure() call is all you need to instrument your project with Logfire for basic Pydantic model monitoring.

Logfire basic usage example with Pydantic

Example showing basic Logfire usage with Pydantic models: ```python from datetime import date import logfire from pydantic import BaseModel logfire.configure() # (1)! class User(BaseModel): name: str country_code: str dob: date user = User(name='Anne', country_code='USA', dob='2000-01-01') logfire.info('user processed: {user!r}', user=user) # (2)! ``` The logfire.configure() call instruments the project with Logfire. The logfire.info() call logs the user object to Logfire with builtin support for Pydantic models.

Pydantic instrumentation with logfire.instrument_pydantic()

You can record information about the validation process automatically by calling logfire.instrument_pydantic(). This call automatically logs validation information for all Pydantic models in your project.

Pydantic instrumentation example

Example of automatic Pydantic instrumentation with Logfire: ```python from datetime import date import logfire from pydantic import BaseModel logfire.configure() logfire.instrument_pydantic() # (1)! class User(BaseModel): name: str country_code: str dob: date User(name='Anne', country_code='USA', dob='2000-01-01') User(name='David', country_code='GBR', dob='invalid-dob') ``` The logfire.instrument_pydantic() call automatically logs validation information for all Pydantic models in your project. Each successful and failed validation is logged in Logfire.

Logfire validation error troubleshooting

Logfire is especially useful when a ValidationError shows up in production and you need the input that caused it. You can investigate spans to get validation details.

Give your agent this brain