init_chat_model
to initialize models:
init_chat_model
, you can instantiate the provider’s model class directly. The model must implement the BaseChatModel interface and support tool calling:
create_react_agent
you can specify the model by its name string, which is a shorthand for initializing the model using init_chat_model
. This allows you to use the model without needing to import or instantiate it directly.
create_react_agent
to dynamically select the model at runtime. This is useful for scenarios where you want to choose a model based on user input, configuration settings, or other runtime conditions.
The selector function must return a chat model. If you’re using tools, you must bind the tools to the model within the selector function.
disable_streaming=True
when initializing the model:
disable_streaming
model.with_fallbacks([...])
:
StreamWriter
.
Refer to the custom streaming documentation for guidance. This approach suits custom workflows where prebuilt agent integration is not necessary.