pydantic_ai.profiles
Describes how requests to a specific model or family of models need to be constructed to get the best results, independent of the model and provider classes used.
Source code in pydantic_ai_slim/pydantic_ai/profiles/__init__.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
from_profile
classmethod
from_profile(profile: ModelProfile | None) -> Self
Build a ModelProfile subclass instance from a ModelProfile instance.
Source code in pydantic_ai_slim/pydantic_ai/profiles/__init__.py
20 21 22 23 24 25 |
|
update
update(profile: ModelProfile | None) -> Self
Update this ModelProfile (subclass) instance with the non-default values from another ModelProfile instance.
Source code in pydantic_ai_slim/pydantic_ai/profiles/__init__.py
27 28 29 30 31 32 33 34 35 36 37 |
|
OpenAIModelProfile
dataclass
Bases: ModelProfile
Profile for models used with OpenAIModel.
ALL FIELDS MUST BE openai_
PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Source code in pydantic_ai_slim/pydantic_ai/profiles/openai.py
11 12 13 14 15 16 17 18 19 |
|
openai_model_profile
openai_model_profile(model_name: str) -> ModelProfile
Get the model profile for an OpenAI model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/openai.py
22 23 24 |
|
OpenAIJsonSchemaTransformer
dataclass
Bases: JsonSchemaTransformer
Recursively handle the schema to make it compatible with OpenAI strict mode.
See https://platform.openai.com/docs/guides/function-calling?api-mode=responses#strict-mode for more details,
but this basically just requires:
* additionalProperties
must be set to false for each object in the parameters
* all fields in properties must be marked as required
Source code in pydantic_ai_slim/pydantic_ai/profiles/openai.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
anthropic_model_profile
anthropic_model_profile(
model_name: str,
) -> ModelProfile | None
Get the model profile for an Anthropic model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/anthropic.py
6 7 8 |
|
google_model_profile
google_model_profile(
model_name: str,
) -> ModelProfile | None
Get the model profile for a Google model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/google.py
11 12 13 |
|
GoogleJsonSchemaTransformer
Bases: JsonSchemaTransformer
Transforms the JSON Schema from Pydantic to be suitable for Gemini.
Gemini which supports a subset of OpenAPI v3.0.3.
Specifically:
* gemini doesn't allow the title
keyword to be set
* gemini doesn't allow $defs
— we need to inline the definitions where possible
Source code in pydantic_ai_slim/pydantic_ai/profiles/google.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
meta_model_profile
meta_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Meta model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/meta.py
7 8 9 |
|
amazon_model_profile
amazon_model_profile(
model_name: str,
) -> ModelProfile | None
Get the model profile for an Amazon model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/amazon.py
7 8 9 |
|
deepseek_model_profile
deepseek_model_profile(
model_name: str,
) -> ModelProfile | None
Get the model profile for a DeepSeek model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/deepseek.py
6 7 8 |
|
grok_model_profile
grok_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Grok model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/grok.py
6 7 8 |
|
mistral_model_profile
mistral_model_profile(
model_name: str,
) -> ModelProfile | None
Get the model profile for a Mistral model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/mistral.py
6 7 8 |
|
qwen_model_profile
qwen_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Qwen model.
Source code in pydantic_ai_slim/pydantic_ai/profiles/qwen.py
7 8 9 |
|