Skip to content

Commit 3418eea

Browse files
committed
Update compartment_id validation for GenAI models.
1 parent fa2d72e commit 3418eea

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ads/llm/langchain/plugins/base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ def is_lc_serializable(cls) -> bool:
5656

5757

5858
class GenerativeAiClientModel(BaseModel):
59+
"""Base model for generative AI embedding model and LLM."""
60+
5961
client: Any #: :meta private:
6062
"""OCI GenerativeAiClient."""
6163

62-
compartment_id: str
64+
compartment_id: str = None
6365
"""Compartment ID of the caller."""
6466

6567
endpoint_kwargs: Dict[str, Any] = {}
@@ -90,7 +92,9 @@ def validate_environment( # pylint: disable=no-self-argument
9092
client_kwargs.update(values["client_kwargs"])
9193
values["client"] = GenerativeAiClient(**auth, **client_kwargs)
9294
# Set default compartment ID
93-
if "compartment_id" not in values and COMPARTMENT_OCID:
94-
values["compartment_id"] = COMPARTMENT_OCID
95-
95+
if not values.get("compartment_id"):
96+
if COMPARTMENT_OCID:
97+
values["compartment_id"] = COMPARTMENT_OCID
98+
else:
99+
raise ValueError("Please specify compartment_id.")
96100
return values

0 commit comments

Comments
 (0)