Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion libs/community/langchain_community/chat_models/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class ChatSnowflakeCortex(BaseChatModel):
)

session: Any = None
"""Snowpark session object."""
"""Snowpark session object. If provided, it will be used instead of creating
a new session from environment variables."""

model: str = "mistral-large"
"""Snowflake cortex hosted LLM model name, defaulted to `mistral-large`.
Expand Down Expand Up @@ -176,6 +177,10 @@ def build_extra(cls, values: Dict[str, Any]) -> Any:

@model_validator(mode="before")
def validate_environment(cls, values: Dict) -> Dict:
# Skip validation if session is already provided
if values.get("session") is not None:
return values

try:
from snowflake.snowpark import Session
except ImportError:
Expand Down