Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
61 views

I'm building a FastAPI application and modeling a forum-style comment system using Pydantic v2. Each comment can contain replies, and those replies can contain more replies, recursively, similar to ...
Mauricio Reisdoefer's user avatar
0 votes
0 answers
76 views

I have rustc, I have cargo, I have c++ build tools, I have everything! but it doesn't work( Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'C:\\Users\\Admin\\Desktop\\ааа проекты\\.venv\\...
Просто Аккаунт's user avatar
2 votes
2 answers
75 views

Let's say I have 2 simple BaseSettings classes that, each, load values from their individual environment files. Let's also say that there is a combined settings class that is based on the first 2 ...
HanSooloo's user avatar
  • 805
Best practices
0 votes
3 replies
51 views

I'm building a Pydantic model where a field's requirement depends on the value of another field. Specifically, I want the cpf field to be required only if the country field is set to "BR". ...
Comic Hell's user avatar
1 vote
1 answer
47 views

I am trying to create a set of POJOs from an OpenAPI specification that is generated from a pydantic data model. The problem I'm hitting is with discriminators. I am currently using the following ...
Rob Spremulli's user avatar
1 vote
1 answer
32 views

I am using LlamaIndex's MetadataFilters to apply a filter to my ChromaDB VectorStoreIndex as a query engine. I am able to set multiple filters if they are using the same FilterCondition but how would ...
NFPortal's user avatar
Best practices
0 votes
2 replies
42 views

Goal How can I use pydantic_settings in pytest? I want to have a .env.test environment file that has dummy values for all the environment variables. Some code has logic that depends on those variables ...
trey hannam's user avatar
-4 votes
0 answers
95 views

Say I have a Pydantic model that can take an Any type. If the user sends in JSON on their end, what will Pydantic do here? Will it fail, or will request be of some known type? Ultimately, I know ...
ammo 45's user avatar
0 votes
0 answers
57 views

I have the following abstract Data class and some concrete subclasses: import abc from typing import TypeVar, Generic, Union from pydantic import BaseModel T = TypeVar('T') class Data(BaseModel, abc....
Relys's user avatar
  • 85
0 votes
1 answer
114 views

I'm trying to use LangChain’s structured output feature with a Gemini model, however, whenever I try to run the chain, I get the error: ValueError: unknown enum label "any" Here’s the code I ...
Not Hatim's user avatar
0 votes
1 answer
73 views

I'm using a field wrap validator in Pydantic with the Annotated pattern, and I want to access the expected/annotated type of a field from within the validator function. Here's an example of what I ...
kviLL's user avatar
  • 443
2 votes
1 answer
161 views

I'm experimenting with Pydantic AI as agentic framework and want to use Notion's remote MCP server as tool for my agent. Remote server's endpoint seems to require OAuth token to be accessed, but I ...
Krešimir Nesek's user avatar
1 vote
0 answers
67 views

I am using pydantic AI and use pydantic BaseModel to set the output_type of the answer. From time to time I encounter a ValidationException. I cannot accurately pinpoint the issue creating this ...
DeerFreak's user avatar
  • 117
1 vote
0 answers
58 views

I have a sqlmodel defined database and I'm having issues with how to use sqlmodel. This is a two-table reduction of my DB. from __future__ import annotations import uuid from datetime import datetime ...
mmachenry's user avatar
  • 1,992
0 votes
0 answers
88 views

I am creating a API to return pydantic backed object, with optional / "fetchable" fields that might not be fetched based on the API parameter passed in. when accessing these optional data ...
XXXHHHH's user avatar
  • 130
3 votes
1 answer
175 views

I would like to solve the following problem with Pydantic (latest version), with Python 3.x. While deserializing, I want to use the field "path", path contains another array that I want to ...
Josh.h's user avatar
  • 115
1 vote
0 answers
83 views

If I create a dynamic model: BarModel = create_model( 'BarModel', apple=(str, 'russet'), banana=(str, 'yellow') And then I want to create another dynamic model with a field of type '...
bmargulies's user avatar
  • 101k
2 votes
1 answer
181 views

My understanding is that to get the pydantic_data_converter to auto convert outputs, you need to pass a function reference, i.e. This properly returns a TestModel result: TestModel = await ...
wonton's user avatar
  • 8,643
-1 votes
1 answer
39 views

I have come across this problem when making my unit tests. from unittest.mock import AsyncMock, patch import pydantic # class Parent(): # Using non-pydantic class works class Parent(pydantic....
Automatico's user avatar
  • 12.9k
-4 votes
1 answer
83 views

I am trying to set up custom validation for pydantic models. According to the the pydantic docs, custom validators can be applied to a field using the Annotated Pattern or field_validator() decorator ...
Cat100's user avatar
  • 121
1 vote
1 answer
68 views

I'd like to extend existing Pydantic types such as FilePath by f.i. adding a file type pattern for validation serialization to JSON schema. Current approach I'd f.i. like to define my custom type ...
JE_Muc's user avatar
  • 5,832
1 vote
0 answers
108 views

So i have these two tools to store and give a file_path for AI-agent class AnalystState(AgentState): file_path: Optional[str] last_tool_called: Optional[str] @tool def update_file_path(...
Vamsi Konakanchi's user avatar
0 votes
1 answer
96 views

I am trying to use a Schema Guided Reasoning approach to develop a system which will classify for me product into one of the categories from predefined list based on its name\description. For that I ...
Maksim Khaitovich's user avatar
0 votes
1 answer
70 views

I have the below pydantic model with 6 columns out of which 2 columns are nullable. from pydantic import BaseModel from typing import Optional class Purchases(BaseModel): customer_id: int ...
LearneR's user avatar
  • 2,591
0 votes
1 answer
62 views

I want to check the type of a Pydantic FieldInfo: from pydantic import BaseModel from pydantic.fields import FieldInfo class Address(BaseModel): street: str city: str postcode: int class ...
MarcoS's user avatar
  • 13.6k
1 vote
1 answer
128 views

I want to set and instantiate the right type based on the value of another field and get typing and autocomplete on it. I want this to happen automatically when the class is instantiated: ...
red888's user avatar
  • 32.3k
4 votes
1 answer
208 views

Assume that I have these Beanie Documents which are based, by the way, on Pydantic Models: File name: models.py from beanie import Document, Link class A(Document): first: int second: str ...
Ambitions's user avatar
  • 2,643
1 vote
1 answer
61 views

I want a pydantic Model that can take exactly one of two optional arguments, where the missing argument will be calculated from the other. Consider this: from pydantic import BaseModel, ...
Engensmax's user avatar
  • 173
0 votes
0 answers
205 views

For use with pydantic, I want to create recursive type aliases at runtime. "Normal" type aliases are possible like this: from typing import TypeAliasType alias = TypeAliasType("alias&...
502E532E's user avatar
  • 581
0 votes
0 answers
30 views

Background Rust has the ability to express tagged-union as follows: pub enum FooBar { Foo { a: u32 }, Bar { b: String }, } which serialize to: { "foo": { "a": 123 } } // ...
JP-Ellis's user avatar
  • 457
2 votes
1 answer
105 views

I’m building a RAG application using LangChain and Watsonx AI with Streamlit. I want to create a LangChainInterface instance using my IBM Watsonx API credentials, but I’m getting the following ...
Chamika Udayanga's user avatar
1 vote
0 answers
97 views

I am trying to build a pydantic AI agent When defining my tools, when I pass in my tools along with my agent as parameter as chat_agent = Agent( model=create_chat_model(), output_type=...
Prabhleen Bindra's user avatar
0 votes
1 answer
84 views

I'm working on a basecode which has some classic pydantic models (from BaseModel). But I'm also implementing custom models through implementing __get_pydantic_core_schema__ and ...
gau000's user avatar
  • 45
0 votes
0 answers
139 views

I am using lofgire to send traces, logs and metrics to grafana-otel container. However, in the grafana UI (reachable unter http://localhost:3000 and login is pw: admin & user: admin), only traces ...
JKupzig's user avatar
  • 1,303
8 votes
0 answers
2k views

I'm using LangChain with GPT-OSS models (served via Hyperbolic) to generate and evaluate answers. My eval model is supposed to return a JSON object (using a Pydantic schema with the class name '...
Sankalp Dhupar's user avatar
2 votes
2 answers
260 views

I'm currently working on an api using fastapi and sqlmodel. I'm new to these two and I might have missed something. I have a user model with an e-mail field. So no email outside my organization is ...
somedev's user avatar
  • 49
1 vote
2 answers
119 views

I am trying to do a validation on passwords where if they dont match, return an error. But I want to assign the error to field. class RequestFile( BaseModel ): password: str = Field(..., ...
Mr. Kenneth's user avatar
  • 1,047
2 votes
1 answer
404 views

Here is my example code: from pathlib import Path from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict( yaml_file=...
rzlvmp's user avatar
  • 9,864
1 vote
2 answers
253 views

I'm writing integration tests with pytest for my FastAPI/SQLModel app, and I was looking for a way to freeze time directly inside the app. While freezegun works fine in basic scenarios like unit tests,...
Mister Balise's user avatar
1 vote
0 answers
79 views

I'm using FastAPI with Pydantic's BaseModel, and I'm trying to define optional fields with a default value of None. However, in the Swagger UI (auto-generated docs), FastAPI shows "string" ...
Raphaël Landry-Versailles's user avatar
2 votes
1 answer
123 views

python 3.13 pydantic 2.10.5 mypy 1.16.0 how to properly annotate return of typing._SpecialForm, specifically typing.Annotated? I'm using mypy as type checker. from functools import partial from ...
Alexander Konukhov's user avatar
0 votes
1 answer
67 views

I'm trying to develop filtering/ordering/pagination functionality for FastAPI applications. For now I'm facing difficulty with separating filtering and sorting. The code below generates undesirable ...
Альберт Александров's user avatar
1 vote
0 answers
159 views

The Pydantic documentation explicitly describes the order of field validators, but what about model_validators? In what order do model_validators run? Specifically, how are they ordered in an ...
kviLL's user avatar
  • 443
0 votes
1 answer
1k views

I'm working on a python project created using uv on a ubuntu system. I activated virtual environment using source .venv/bin/activate which python points to /home/username/my-project/.venv/bin/python ...
Rahim T.S's user avatar
1 vote
1 answer
95 views

I have the question same with link Pydantic does not validate the key/values of dict fields from typing import Dict from pydantic import BaseModel class TableModel(BaseModel): table: Dict[str, ...
nelson_metaheuristic's user avatar
5 votes
1 answer
816 views

Is there any way to change the validation messages from pydantic? The problem is this: I want to return these validation messages to my frontend but not all of the users prefer the language english ...
Clyde's user avatar
  • 62
0 votes
0 answers
69 views

I have been using pydantic and FastAPI (separately and together) for a couple of years now and it's been great - until now. I am trying to setup a POST API with a body that accepts a valid URL that ...
Diaa Eldin Malek's user avatar
0 votes
1 answer
220 views

FastMCP's documentation states that: When you add return type annotations, FastMCP automatically generates output schemas to validate the structured data and enables clients to deserialize results ...
omer's user avatar
  • 1,476
2 votes
1 answer
97 views

Why would the following give a linter error in the second case but not the first: # OK: type MyAnnotatedType = Annotated[int | None, Field(strict=True)] # Error: Invalid type alias: expression is not ...
qix's user avatar
  • 8,064
0 votes
0 answers
159 views

Why cannot import pydantic_ai with pydantic_ai in site-packages? enter image description here enter image description here "D:\PYTHON PROJ\AIFileAgent\.venv\Scripts\python.exe" "D:\...
yiming li's user avatar

1
2 3 4 5
48