diff --git a/cookbook/openai_v1_cookbook.ipynb b/cookbook/openai_v1_cookbook.ipynb index 3fc98346f2a..de1675d7ffb 100644 --- a/cookbook/openai_v1_cookbook.ipynb +++ b/cookbook/openai_v1_cookbook.ipynb @@ -50,7 +50,7 @@ { "data": { "text/plain": [ - "AIMessage(content='The image appears to be a diagram illustrating the architecture or components of a software system')" + "AIMessage(content='The image appears to be a diagram representing the architecture or components of a software platform named \"LangChain.\" This diagram outlines various layers and elements of the platform, which seems to be related to language processing or computational linguistics, as suggested by the context clues in the names of the components.\\n\\nHere\\'s a breakdown of the components shown:\\n\\n- **LangSmith**: This seems to be a tool or suite related to testing, evaluation, monitoring, feedback, and annotation within the platform.\\n\\n- **LangServe**: This could represent a service layer that exposes the platform\\'s capabilities as REST API endpoints.\\n\\n- **Templates**: These are likely reference applications provided as starting points or examples for users of the platform.\\n\\n- **Chains, agents, agent executors**: This section describes the common application logic, perhaps indicating that the platform uses a chain of agents or processes to execute tasks.\\n\\n- **Model I/O**: This includes the components related to input/output processing for a model, like prompt, example selector, model, and output parser.\\n\\n- **Retrieval**: These components are involved in retrieving documents, splitting text, and managing embeddings and vector stores, which are important for tasks like search and information retrieval.\\n\\n- **Agent tooling**: This might refer to the tools used for creating,')" ] }, "execution_count": 2, @@ -59,7 +59,7 @@ } ], "source": [ - "chat = ChatOpenAI(model=\"gpt-4-vision-preview\")\n", + "chat = ChatOpenAI(model=\"gpt-4-vision-preview\", max_tokens=256)\n", "chat.invoke(\n", " [\n", " HumanMessage(\n", diff --git a/libs/langchain/langchain/chat_models/openai.py b/libs/langchain/langchain/chat_models/openai.py index 1c8a0a92b9b..d5127b86e8e 100644 --- a/libs/langchain/langchain/chat_models/openai.py +++ b/libs/langchain/langchain/chat_models/openai.py @@ -323,7 +323,7 @@ class ChatOpenAI(BaseChatModel): "temperature": self.temperature, **self.model_kwargs, } - if "vision" not in self.model_name: + if self.max_tokens is not None: params["max_tokens"] = self.max_tokens return params