mirror of
https://github.com/hwchase17/langchain.git
synced 2026-03-18 19:18:48 +00:00
Removed: - `libs/core/langchain_core/chat_history.py`: `add_user_message` and `add_ai_message` in favor of `add_messages` and `aadd_messages` - `libs/core/langchain_core/language_models/base.py`: `predict`, `predict_messages`, and async versions in favor of `invoke`. removed `_all_required_field_names` since it was a wrapper on `get_pydantic_field_names` - `libs/core/langchain_core/language_models/chat_models.py`: `callback_manager` param in favor of `callbacks`. `__call__` and `call_as_llm` method in favor of `invoke` - `libs/core/langchain_core/language_models/llms.py`: `callback_manager` param in favor of `callbacks`. `__call__`, `predict`, `apredict`, and `apredict_messages` methods in favor of `invoke` - `libs/core/langchain_core/prompts/chat.py`: `from_role_strings` and `from_strings` in favor of `from_messages` - `libs/core/langchain_core/prompts/pipeline.py`: removed `PipelinePromptTemplate` - `libs/core/langchain_core/prompts/prompt.py`: `input_variables` param on `from_file` as it wasn't used - `libs/core/langchain_core/tools/base.py`: `callback_manager` param in favor of `callbacks` - `libs/core/langchain_core/tracers/context.py`: `tracing_enabled` in favor of `tracing_enabled_v2` - `libs/core/langchain_core/tracers/langchain_v1.py`: entire module - `libs/core/langchain_core/utils/loading.py`: entire module, `try_load_from_hub` - `libs/core/langchain_core/vectorstores/in_memory.py`: `upsert` in favor of `add_documents` - `libs/standard-tests/langchain_tests/integration_tests/chat_models.py` and `libs/standard-tests/langchain_tests/unit_tests/chat_models.py`: `tool_choice_value` as models should accept `tool_choice="any"` - `langchain` will consequently no longer expose these items if it was previously --------- Co-authored-by: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com> Co-authored-by: Caspar Broekhuizen <caspar@langchain.dev> Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: Christophe Bornet <cbornet@hotmail.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: Sadra Barikbin <sadraqazvin1@yahoo.com> Co-authored-by: Vadym Barda <vadim.barda@gmail.com>
langchain-openai
This package contains the LangChain integrations for OpenAI through their openai SDK.
Installation and Setup
- Install the LangChain partner package
pip install langchain-openai
- Get an OpenAI api key and set it as an environment variable (
OPENAI_API_KEY)
Chat model
See a usage example.
from langchain_openai import ChatOpenAI
If you are using a model hosted on Azure, you should use different wrapper for that:
from langchain_openai import AzureChatOpenAI
For a more detailed walkthrough of the Azure wrapper, see AzureChatOpenAI
Text Embedding Model
See a usage example
from langchain_openai import OpenAIEmbeddings
If you are using a model hosted on Azure, you should use different wrapper for that:
from langchain_openai import AzureOpenAIEmbeddings
For a more detailed walkthrough of the Azure wrapper, see AzureOpenAIEmbeddings
LLM (Legacy)
LLM refers to the legacy text-completion models that preceded chat models. See a usage example.
from langchain_openai import OpenAI
If you are using a model hosted on Azure, you should use different wrapper for that:
from langchain_openai import AzureOpenAI
For a more detailed walkthrough of the Azure wrapper, see Azure OpenAI