You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agents.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,31 @@ You can also pass messages from previous runs to continue a conversation or prov
101
101
nest_asyncio.apply()
102
102
```
103
103
104
+
### Additional Configuration
105
+
106
+
PydanticAI offers a [`settings.ModelSettings`][pydantic_ai.settings.ModelSettings] structure to help you fine tune your requests.
107
+
This structure allows you to configure common parameters that influence the model's behavior, such as `temperature`, `max_tokens`,
108
+
`timeout`, and more.
109
+
110
+
There are two ways to apply these settings:
111
+
1. Passing to `run{_sync,_stream}` functions via the `model_settings` argument. This allows for fine-tuning on a per-request basis.
112
+
2. Setting during [`Agent`][pydantic_ai.agent.Agent] initialization via the `model_settings` argument. These settings will be applied by default to all subsequent run calls using said agent. However, `model_settings` provided during a specific run call will override the agent's default settings.
113
+
114
+
For example, if you'd like to set the `temperature` setting to `0.0` to ensure less random behavior,
115
+
you can do the following:
116
+
117
+
```py
118
+
from pydantic_ai import Agent
119
+
120
+
agent = Agent('openai:gpt-4o')
121
+
122
+
result_sync = agent.run_sync(
123
+
'What is the capital of Italy?', model_settings={'temperature': 0.0}
124
+
)
125
+
print(result_sync.data)
126
+
#> Rome
127
+
```
128
+
104
129
## Runs vs. Conversations
105
130
106
131
An agent **run** might represent an entire conversation — there's no limit to how many messages can be exchanged in a single run. However, a **conversation** might also be composed of multiple runs, especially if you need to maintain state between separate interactions or API calls.
0 commit comments