mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 20:09:01 +00:00
community[minor]: add ChatSnowflakeCortex
chat model (#21490)
**Description:** This PR adds a chat model integration for [Snowflake Cortex](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions), which gives an instant access to industry-leading large language models (LLMs) trained by researchers at companies like Mistral, Reka, Meta, and Google, including [Snowflake Arctic](https://www.snowflake.com/en/data-cloud/arctic/), an open enterprise-grade model developed by Snowflake. **Dependencies:** Snowflake's [snowpark](https://pypi.org/project/snowflake-snowpark-python/) library is required for using this integration. **Twitter handle:** [@gethouseware](https://twitter.com/gethouseware) - [x] **Add tests and docs**: 1. integration tests: `libs/community/tests/integration_tests/chat_models/test_snowflake.py` 2. unit tests: `libs/community/tests/unit_tests/chat_models/test_snowflake.py` 3. example notebook: `docs/docs/integrations/chat/snowflake.ipynb` - [x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/
This commit is contained in:
@@ -51,6 +51,7 @@ EXPECTED_ALL = [
|
||||
"QianfanChatEndpoint",
|
||||
"VolcEngineMaasChat",
|
||||
"ChatOctoAI",
|
||||
"ChatSnowflakeCortex",
|
||||
]
|
||||
|
||||
|
||||
|
@@ -0,0 +1,24 @@
|
||||
"""Test ChatSnowflakeCortex."""
|
||||
|
||||
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
||||
|
||||
from langchain_community.chat_models.snowflake import _convert_message_to_dict
|
||||
|
||||
|
||||
def test_messages_to_prompt_dict_with_valid_messages() -> None:
|
||||
messages = [
|
||||
SystemMessage(content="System Prompt"),
|
||||
HumanMessage(content="User message #1"),
|
||||
AIMessage(content="AI message #1"),
|
||||
HumanMessage(content="User message #2"),
|
||||
AIMessage(content="AI message #2"),
|
||||
]
|
||||
result = [_convert_message_to_dict(m) for m in messages]
|
||||
expected = [
|
||||
{"role": "system", "content": "System Prompt"},
|
||||
{"role": "user", "content": "User message #1"},
|
||||
{"role": "assistant", "content": "AI message #1"},
|
||||
{"role": "user", "content": "User message #2"},
|
||||
{"role": "assistant", "content": "AI message #2"},
|
||||
]
|
||||
assert result == expected
|
Reference in New Issue
Block a user