From 550c410271acad37c0e81fac2926b7a8b6cd0481 Mon Sep 17 00:00:00 2001 From: paxiaatucsdedu Date: Tue, 21 Oct 2025 14:54:20 -0700 Subject: [PATCH 1/2] Add instructions for token limit parameters fro OpenAI models Add instructions for token limit parameters fro OpenAI models --- libs/oci/README.md | 9 ++++++++- libs/oci/langchain_oci/chat_models/oci_generative_ai.py | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/oci/README.md b/libs/oci/README.md index 2266d10..bd5f8b3 100644 --- a/libs/oci/README.md +++ b/libs/oci/README.md @@ -30,7 +30,14 @@ This repository includes two main integration categories: ```python from langchain_oci import ChatOCIGenAI -llm = ChatOCIGenAI() +llm = ChatOCIGenAI( + model_id="MY_MODEL_ID", + service_endpoint="MY_SERVICE_ENDPOINT", + compartment_id="MY_COMPARTMENT_ID", + model_kwargs={"max_tokens": 1024}, # Use max_completion_tokens instead of max_tokens for OpenAI models + auth_profile="MY_AUTH_PROFILE", + is_stream=True, + auth_type="SECURITY_TOKEN" llm.invoke("Sing a ballad of LangChain.") ``` diff --git a/libs/oci/langchain_oci/chat_models/oci_generative_ai.py b/libs/oci/langchain_oci/chat_models/oci_generative_ai.py index c4d8dc3..e6f620d 100644 --- a/libs/oci/langchain_oci/chat_models/oci_generative_ai.py +++ b/libs/oci/langchain_oci/chat_models/oci_generative_ai.py @@ -1058,6 +1058,15 @@ def _prepare_request( if stop is not None: _model_kwargs[self._provider.stop_sequence_key] = stop + # Warn if using max_tokens with OpenAI models + if self.model_id and self.model_id.startswith("openai.") and "max_tokens" in _model_kwargs: + import warnings + warnings.warn( + f"OpenAI models require 'max_completion_tokens' instead of 'max_tokens'.", + UserWarning, + stacklevel=2 + ) + chat_params = {**_model_kwargs, **kwargs, **oci_params} if not self.model_id: From 6b14fac88e6cbe9aa191c1f9ca95844ef1c507d0 Mon Sep 17 00:00:00 2001 From: paxiaatucsdedu Date: Tue, 28 Oct 2025 14:47:51 -0700 Subject: [PATCH 2/2] Bump oci requirement to >=2.161.0 Upgrade oci dependency from >=2.144.0 to >=2.161.0 --- libs/oci/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/oci/pyproject.toml b/libs/oci/pyproject.toml index c5bda85..150fba6 100644 --- a/libs/oci/pyproject.toml +++ b/libs/oci/pyproject.toml @@ -14,7 +14,7 @@ license = "UPL" python = ">=3.9,<4.0" langchain-core = ">=0.3.20,<1.0.0" langchain = ">=0.3.20,<1.0.0" -oci = ">=2.144.0" +oci = ">=2.161.0" pydantic = ">=2,<3" aiohttp = ">=3.12.14"