Send a link to your students to track their progress
19 Terms
1
New cards
What role do models play within agents?
They are the reasoning engine of agents: they drive the agent's decision-making process; determining which tools to call; how to interpret results; and when to provide a final answer.
2
New cards
What two ways can models be used in LangChain?
1) With agents — dynamically specified when creating an agent. 2) Standalone — called directly outside the agent loop for tasks like text generation; classification; or extraction.
3
New cards
What is the easiest way to initialize a standalone model in LangChain?
Use `init_chat_model` to initialize a model from a chat model provider of your choice.
4
New cards
Why do new model names work immediately without a LangChain update?
Because provider packages pass model names directly to the provider's API.
5
New cards
What format lets you specify both a model and its provider in a single argument?
The `'provider:model'` format; e.g. `'openai:o1'`.
6
New cards
What does the `temperature` parameter control on a chat model?
It controls the randomness of the model's output — higher values make responses more creative; lower values make them more deterministic.
7
New cards
What does the `max_tokens` parameter control?
It limits the total number of tokens in the response; effectively controlling how long the output can be.
8
New cards
What does the `timeout` parameter control?
The maximum time (in seconds) to wait for a response from the model before canceling the request.
9
New cards
What is the default value of `max_retries`; and what does it represent?
Default is 6 — the maximum number of attempts to resend a failed request (network timeouts; rate limits).
10
New cards
What backoff strategy do retries use?
Exponential backoff with jitter.
11
New cards
Which types of errors are retried automatically?
Network errors; rate limits (429); and server errors (5xx).
12
New cards
Which types of errors are NOT retried automatically?
Client errors such as 401 (unauthorized) or 404.
13
New cards
For long-running agent tasks on unreliable networks; what value is suggested for `max_retries`?
Increasing it to 10–15.
14
New cards
What can you do with a chat model instance after configuring `max_retries` and `timeout`?
Pass that instance to `create_agent`; `create_deep_agent`; or call it standalone.
15
New cards
python import os from langchain.chat_models import ________ os.________['OPENAI_API_KEY'] = 'sk-.....' model = init_chat_model('gpt-4o-mini') response = model.________('Why do parrots talk')
```python import os from langchain.chat_models import init_chat_model os.environ['OPENAI_API_KEY'] = 'sk-.....' model = init_chat_model('gpt-4o-mini') response = model.invoke('Why do parrots talk') ```
16
New cards
python model = init_chat_model( 'claude-sonnet-4-6'; # Kwargs passed to the model: ________=0.7; timeout=30; ________=1000; max_retries=6; # Default; increase for unreliable networks )
```python model = init_chat_model( 'claude-sonnet-4-6'; # Kwargs passed to the model: temperature=0.7; timeout=30; max_tokens=1000; max_retries=6; # Default; increase for unreliable networks ) ```
17
New cards
python from langchain.chat_models import init_chat_model model = ________( 'google_genai:gemini-3.6-flash'; ________=10; # Increase for unreliable networks (default: 6) timeout=120; # Seconds; increase for slow connections )
```python from langchain.chat_models import init_chat_model model = init_chat_model( 'google_genai:gemini-3.6-flash'; max_retries=10; # Increase for unreliable networks (default: 6) timeout=120; # Seconds; increase for slow connections ) ```